Question: 1. A class can include a definition of an interface that contains default methods. Select one: True False 2. Given the following code snippet: Car[]
1.
A class can include a definition of an interface that contains default methods.
Select one:
True
False
2.
Given the following code snippet:
Car[] carsArray=new Car[2];
Car car1=new Car("Car1");
Car car2=new Car("Car2", 7);
carsArray[0]=car1;
carsArray[1]=car2;
Car max=(Car)fp.getMaxObject(carsArray);
Which of the following reflects the appropriate definition (signature and behavior) of the getMaxObject method:
a.
default
{
// HashMap.Entry
E max=objects.get(0);
for(HashMap.Entry
{
if(entries.getValue().compareTo(max) > 0) max= entries.getValue();
}
return max;
}
b.
default
{
T max=objects[0];
for(int i=1;i { if(objects[i].compareTo(max) > 0 ) max=objects[i]; } return max; } c. default { T max=objects[0]; for(int i=1;i { if(objects[i].compareTo(max) > 0 ) max=objects[i]; } return max; } d. default T getMaxObject(T[] objects) { T max=objects[0]; for(int i=1;i { if(objects[i].compareTo(max) > 0 ) max=objects[i]; } return max; } 3. The cloneable() method is part of the Cloneable interface methods. Select one: True False 4. Which of the following is a mutable class in java? Select one: a. java.lang.StringBuilder b. java.lang.String c. java.lang.Byte d. java.lang.Short 5. One of the following is a valid statement for creating a new ArrayList to store Circle objects in Java: Select one: a. Circle b. ArrayList c. Circle<> queue=new LinkedList d. Circle
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
