0% found this document useful (0 votes)
9 views1 page

arraylist_worksheet1_java_aplus-2

Uploaded by

ucarti3r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

arraylist_worksheet1_java_aplus-2

Uploaded by

ucarti3r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

A+ Computer Science - ArrayList Worksheet 1

DIRECTIONS : Fill in each blank with the correct answer/output. Assume each
statement happens in order and that one statement may affect the next statement.

String st = "sambenandwilerawesome";
ArrayList<String> sam;
sam = new ArrayList<String>();
sam.add( "ben" );
sam.add( "wil" );
sam.set( 1, "cat" );
sam.add( "dog" );
sam.add( "pig" );
Collections.sort( sam );
sam.remove(2);

The first index position in an array is __________. 1. _______________

System.out.print( st.charAt(0) ); // LINE 2 2. _______________

System.out.print( st.charAt(2) ); // LINE 3 3. _______________

System.out.print( st.charAt(5) ); // LINE 4 4. _______________

System.out.print( sam.get(0) ); // LINE 5 5. _______________

System.out.print( sam.get(0).charAt(0)); // LINE 6 6. _______________

System.out.print( sam.get(2) ); // LINE 7 7. _______________

System.out.print( sam.indexOf("ben")); // LINE 8 8. _______________

System.out.print( sam.contains("sam")); // LINE 9 9. _______________

System.out.print( sam.isEmpty()); // LINE 10 10. _______________

sam.set(1, "\\\\");
System.out.print( sam ); // LINE 11 11. _______________

sam.remove(1);
System.out.print( sam ); // LINE 12 12. _______________

sam.add("one");
System.out.print( sam ); // LINE 13 13. _______________

sam.add(0,"five");
System.out.print( sam ); // LINE 14 14. _______________

sam.clear();
System.out.print( sam ); // LINE 15 15. _______________

© A+ Computer Science - Worksheet – www.apluscompsci.com

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy