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 > E getMaxObject(HashMap objects)

{

// HashMap.Entry firstElement = objects.entrySet().iterator().next();

E max=objects.get(0);

for(HashMap.Entry entries: objects.entrySet())

{

if(entries.getValue().compareTo(max) > 0) max= entries.getValue();

}

return max;

}

b.

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;

}

c.

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;

}

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 queue=new ArrayList();

b.

ArrayList queue=new ArrayList<>();

c.

Circle<> queue=new LinkedList();

d.

Circle queue=new ArrayList();

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!