Question: Please answer quickly Given the following code snippet: default E getObjectWithMaxPrice(HashMap objects) { HashMap.Entry elements = objects.entrySet().iterator().next(); E max=elements.getValue(); for(HashMap.Entry entries: objects.entrySet()) { if(entries.getValue().compareTo(max) >

Please answer quickly

Given the following code snippet:

default > E getObjectWithMaxPrice(HashMap objects) {

HashMap.Entry elements = objects.entrySet().iterator().next();

E max=elements.getValue();

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

{

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

}

return max;

}

a.

both T and E must be objects of Wrapper classes

b.

None of these

c.

both T and E must be of primitive types

d.

only T must be an object of a Wrapper class

2-

One of the following is a valid for-loop syntax to iterate through the elements of a HashMap:

Select one:

a.

for(HashMap.Entry wordsPart1.entrySet())

{

System.out.println("Key: "+ entry.getKey() + "\tValue: "+entry.getValue());

}

b.

None of these

c.

for(HashMap.Entry entry:wordsPart1.entrySet())

{

System.out.println("Key: "+ entry.getKey() + "\tValue: "+entry.getValue());

}

d.

for(HashMap entry:wordsPart1.entrySet())

{

System.out.println("Key: "+ entry.getKey() + "\tValue: "+entry.getValue());

}

3-

For the ReadWords class that is used to read the content of a given text file, which of the following represent a valid no-arguments constructor definition?

Select one:

a.

public ReadWords() throws FileNotFoundException { . . . }

b.

public void ReadWords() throws FileNotFoundException { . . . }

c.

None of these

d.

public ArrayList ReadWords() throws FileNotFoundException { . . . }

4-

In the following code, Specs must be an inner class to class MobilePhone:

public MobilePhone(String name, String brand,double price,int ram,int hd,int cameras,String os)

{

this.mobileName=name;

this.mobileBrand=brand;

this.mobilePrice=price;

this.specs=new Specs(ram, hd, cameras, os);

}

Select one:

True

False

5-

The following code creates ------------------------ Computer objects in memory.

Computer[] comp2 = new Computer[5]{new Computer("Apple", "CMA014"), new Computer("Lenovo", "CMA014"), new Computer("Dell", "CMA014"), new Computer("HP", "CMA014"), new Computer("Toshiba", "CMA014")};

Select one:

a.

the code is not valid

b.

one

c.

five

d.

four

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!