Weekend Sale - Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: sntaclus

Given the code fragment:

Which code fragment, when inserted at line 7, enables printing 100?

A.

Function funRef = e –> e + 10;Integer result = funRef.apply(value);

B.

IntFunction funRef = e –> e + 10;Integer result = funRef.apply (10);

C.

ToIntFunction funRef = e –> e + 10;int result = funRef.applyAsInt (value);

D.

ToIntFunction funRef = e –> e + 10;int result = funRef.apply (value);

You want to create a singleton class by using the Singleton design pattern.

Which two statements enforce the singleton nature of the design? (Choose two.)

A.

Make the class static.

B.

Make the constructor private.

C.

Override equals() and hashCode() methods of the java.lang.Object class.

D.

Use a static reference to point to the single instance.

E.

Implement the Serializable interface.

Given:

From what threading problem does the program suffer?

A.

race condition

B.

deadlock

C.

starvation

D.

livelock

Given:

and the code fragment:

What is the result?

A.

truetrue

B.

falsetrue

C.

falsefalse

D.

truefalse

Given:

What is the result?

A.

IT:null

B.

A NullPointerException is thrown at run time.

C.

A compilation error occurs.

D.

IT:0.0

Given the code fragment:

Which two code fragments, when inserted at line n1 independently, result in the output PEEK: Unix?

A.

.anyMatch ();

B.

.allMatch ();

C.

.findAny ();

D.

.noneMatch ();

E.

.findFirst ();

Given the code fragment:

public void recDelete (String dirName) throws IOException {

File [ ] listOfFiles = new File (dirName) .listFiles();

if (listOfFiles ! = null && listOfFiles.length >0) {

for (File aFile : listOfFiles) {

if (aFile.isDirectory ()) {

recDelete (aFile.getAbsolutePath ());

} else {

if (aFile.getName ().endsWith (“.class”))

aFile.delete ();

}

}

}

}

Assume that Projects contains subdirectories that contain .class files and is passed as an argument to the recDelete () method when it is invoked.

What is the result?

A.

The method deletes all the .class files in the Projects directory and its subdirectories.

B.

The method deletes the .class files of the Projects directory only.

C.

The method executes and does not make any changes to the Projects directory.

D.

The method throws an IOException.

Given:

class Vehicle implements Comparable{

int vno;

String name;

public Vehicle (int vno, String name) {

this.vno = vno,;

this.name = name;

}

public String toString () {

return vno + “:” + name;

}

public int compareTo(Vehicle o) {

return this.name.compareTo(o.name);

}

and this code fragment:

Set vehicles = new TreeSet <> ();

vehicles.add(new Vehicle (10123, “Ford”));

vehicles.add(new Vehicle (10124, “BMW”));

System.out.println(vehicles);

What is the result?

A.

[10123:Ford, 10124:BMW]

B.

[10124:BMW, 10123:Ford]

C.

A compilation error occurs.

D.

A ClassCastException is thrown at run time.

Given the code fragment:

List empDetails = Arrays.asList(“100, Robin, HR”, “200, Mary, AdminServices”,“101, Peter, HR”);

empDetails.stream()

.filter(s-> s.contains(“r”))

.sorted()

.forEach(System.out::println); //line n1

What is the result?

A.

100, Robin, HR101, Peter, HR

B.

E. A compilation error occurs at line n1.

C.

101, Peter, HR200, Mary, AdminServices

D.

100, Robin, HR200, Mary, AdminServices101, Peter, HR

Which two reasons should you use interfaces instead of abstract classes? (Choose two.)

A.

You expect that classes that implement your interfaces have many common methods or fields, or require access modifiers other than public.

B.

You expect that unrelated classes would implement your interfaces.

C.

You want to share code among several closely related classes.

D.

You want to declare non-static on non-final fields.

E.

You want to take advantage of multiple inheritance of type.