Question: 1 . An advantage of using the ArrayList class over the Arrays class is that an ArrayList . a . can hold more elements b
An advantage of using the ArrayList class over the Arrays class is that an ArrayList
acan hold more elements
b is dynamically resizable
c supports use with indexes
d requires less memory
An ArrayList can hold
a any primitive type
b any numeric type
c any object type
d only objects
The number of items an ArrayList can hold is its
a sufficiency
b scope
c range
d capacity
If you have declared an ArrayList of Strings named myStrings, which of the following is not a legal method call?
a myStrings.addonion;
b myStrings.removeonion;
c int s myStrings.size;
d myStrings.add "leek";
Suppose you have declared an ArrayList of Integers named numbers with a capacity of and that you have assigned values to the first six elements. Which of the following is not legal?
a numbers.get;
b numbers.set;
c numbers.get;
d numbers.add;
When you create a class from which you will instantiate objects to store in an ArrayList,
a you must create a toString method
b you must create a compareTo method
c you must create both a toString method and a compareTo method
d you are not required to create either a toString method or a compareTo method
The method that can be used to sort an ArrayList is
a Collections.sort
b ArrayList.sort
c List.sort
d Sorting.sort
All of the following classes contain a builtin compareTo method except
a Integer
b String
c Scanner
d Double
If you want to use Collections.sort with a class you have created, you must
a write your own compareTo method
b overload the and operators
c write your own toString method
d write both a compareTo method and toString method
Which is not a requirement when you create a compareTo method that overrides the Object class compareTo method?
a It must accept a parameter.
b Its return type must be boolean.
c It should return a value that is or
d It must be named compareTo
Suppose you have created a Student class compareTo method that is based on the value of a private idNum field.
Assume the class contains a public getId method that returns the idNum value. Also suppose that stus idNum is and that stus idNum is
Which of the following returns
a stucompareTostu
b stucompareTostu
c stucompareTostuidNum
d stugetIdcompareTo stugetId
Which of the following is true?
a The ArrayList class works better than a LinkedList when you must move a lot of the data stored there.
b The ArrayList class works better than a LinkedList when you have to sequentially retrieve a lot of data.
c An ArrayList always works more efficiently than a LinkedList.
d An ArrayList always is less efficient than using a LinkedList.
An object that can be used in a foreach loop to process the elements in a Collection is an
a index
b subscript
c repeater
d iterator
A generic class is one that uses an
a overloaded method
b generic method
c type parameter
d empty method
A generic method
a resides in a generic class
b cannot be overloaded
c can contain only one parameter
d uses at least one type parameter
A generic method
a must have a type parameter that represents a reference type
b must return a generic parameter
c must have an empty body that is created at runtime
d can have no more than one type parameter
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
