Question
Need help answering these questions 1: In programming, a(n) is a group of objects that can be operated on together. a) collision b) anthology c)
Need help answering these questions
1: In programming, a(n) is a group of objects that can be operated on together.
a) collision
b) anthology
c) assemblage
d) collection
2: A difference between a collection and an array is that a collection .
a) can hold references
b)can be passed to a method
c)is dynamically resizable
d)can hold primitive data types
3: The Java Collections framework contains .
a)interfaces, but not classes
b)classes, but not interfaces
c)both interfaces and classes
d)neither interfaces nor classes
4:The List interface .
allows items to be inserted after creation
cannot contain duplicate elements
does not allow items to be removed
cannot contain more than 100 elements
5:An advantage of using the ArrayList class over the Arrays class is that an ArrayList .
can hold more elements
is dynamically resizable
supports use with indexes
requires less memory
6:An ArrayList can hold .
any primitive type
any numeric type
any object type
only 10 objects
7:The number of items an ArrayList can hold is its .
sufficiency
scope
range
capacity
8:If you have declared an ArrayList of Strings named myStrings, which of the following is not a legal method call?
myStrings.add("onion");
myStrings.remove("onion");
int s = myStrings.size();
myStrings.add(0, "leek");
9:Suppose you have declared an ArrayList of Integers named numbers with a capacity of 10, and that you have assigned values to the first six elements. Which of the following is not legal?
numbers.get(9);
numbers.set(1, 55);
numbers.get(5);
numbers.add(77);
10:When you create a class from which you will instantiate objects to store in an ArrayList, .
you must create a toString() method
you must create a compareTo() method
you must create both a toString() method and a compareTo() method
you are not required to create either a toString() method or a compareTo() method
11:The method that can be used to sort an ArrayList is .
Collections.sort()
ArrayList.sort()
List.sort()
Sorting.sort()
12:All of the following classes contain a built-in compareTo() method except .
Integer
String
Scanner
Double
13:If you want to use Collections.sort() with a class you have created, you must .
write your own compareTo() method
overload the < and > operators
write your own toString() method
write both a compareTo() method and toString() method
14:Which is not a requirement when you create a compareTo() method that overrides the Object class compareTo() method?
It must accept a parameter.
Its return type must be boolean.
It should return a value that is 1, 0, or 1.
It must be named compareTo().
15: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 stu1s idNum is 345 and that stu2s idNum is 456. Which of the following returns 1?
stu1.compareTo(stu2)
stu2.compareTo(stu1)
stu2.compareTo(stu1.idNum)
stu1.getId().compareTo (stu2.getId())
16:Which of the following is true?
The ArrayList class works better than a LinkedList when you must move a lot of the data stored there.
The ArrayList class works better than a LinkedList when you have to sequentially retrieve a lot of data.
An ArrayList always works more efficiently than a LinkedList.
An ArrayList always is less efficient than using a LinkedList.
17:An object that can be used in a foreach loop to process the elements in a Collection is a(n) .
index
subscript
repeater
iterator
18:A generic class is one that uses a(n) .
overloaded method
generic method
type parameter
empty method
19:A generic method .
resides in a generic class
cannot be overloaded
can contain only one parameter
uses at least one type parameter
20:A generic method .
must have a type parameter that represents a reference type
must return a generic parameter
must have an empty body that is created at runtime
can have no more than one type parameter
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started