Computer Education Introduction to Computer Science Using Java™ Computer Education Introduction to Computer Science Using Java™   Glencoe Online
Computer Education Home Product Information Site Map Search Contact Us

Students

Self-Assessment Exercises

Chapter 12: Collections
      
  1.Java collections are divided into two main groups: ________ and ________.  
  a.   primitive collections, object collections  
  b.   simple collections, maps  
  c.   simple collections, complex collections  
  d.   Arrays, ArrayLists  
      
  2.The number of elements in the collection myCollection can be obtained with which of the following expressions?  
  a.   myCollection.length  
  b.   myCollection.length()  
  c.   myCollection.size()  
  d.   size(myCollection)  
      
  3.Assume that you have created an ArrayList named myList and that you have stored ten Color objects in it. What is the return type of myList.get(4) ? "  
  a.   boolean  
  b.   int  
  c.   Color  
  d.   Object  
      
  4.Suppose that you create an ArrayList with the statement:

ArrayList myList = new ArrayList();

What can be stored as elements in myList ?
 
  a.   only primitive types  
  b.   only non-primitive types  
  c.   only objects of type ArrayList  
  d.   only objects of type Object  
      
  5.Which of the following statements would you use to store the string “A” at index 2 in the ArrayList myList ?  
  a.   myList.set(2, "A");  
  b.   myList.indexOf(2) = "A";  
  c.   myList[2] = "A";  
  d.   set(myList, 2, "A");  

 

McGraw-Hill Glencoe   The McGraw-Hill Companies
Self-Assessment Exercises
Java Compilers
Source Code
Java Resources
PowerPoint® Presentations
Home