Given the code fragment:
public class Foo {
public static void main (String [ ] args) {
Map
unsortMap.put (10, “z”);
unsortMap.put (5, “b”);
unsortMap.put (1, “d”);
unsortMap.put (7, “e”);
unsortMap.put (50, “j”);
Map
Comparator
@Override public int compare (Integer o1, Integer o2) {return o2.compareTo
(o2); } } );
treeMap.putAll (unsortMap);
for (Map.Entry
System.out.print (entry.getValue () + “ “);
}
}
}
What is the result?
Given the code fragment:
Which code fragment, when inserted at line n1, enables the code to print /First.txt?
Given:
class Vehicle {
int vno;
String name;
public Vehicle (int vno, String name) {
this.vno = vno,;
this.name = name;
}
public String toString () {
return vno + “:” + name;
}
}
and this code fragment:
Set
vehicles.add(new Vehicle (10123, “Ford”));
vehicles.add(new Vehicle (10124, “BMW”));
System.out.println(vehicles);
What is the result?
Given the definition of the Employee class:
and this code fragment:
What is the result?
Given:
Your design requires that:
Which code fragment should be added at line n1 to express this invariant condition?
Given the code fragment:
UnaryOperator
List
loanValues.stream()
.filter(lv -> lv >= 1500)
.map(lv -> uo1.apply(lv))//line n2
.forEach(s -> System.out.print(s + “ “));
What is the result?
Given the code fragment:
Path path1 = Paths.get(“/app/./sys/”);
Path res1 = path1.resolve(“log”);
Path path2 = Paths.get(“/server/exe/”);
Path res1 = path2.resolve(“/readme/”);
System.out.println(res1);
System.out.println(res2);
What is the result?
Given:
public class Product {
int id; int price;
public Product (int id, int price) {
this.id = id;
this.price = price;
}
Public String toString () { return id + “:” + price;)
}
and the code fragment:
List
new Product (2, 30),
new Product (3, 20));
Product p = products.stream().reduce(new Product (4, 0), (p1, p2) -> {
p1.price+=p2.price;
return new Product (p1.id, p1.price);});
products.add(p);
products.stream().parallel()
.reduce((p1, p2) - > p1.price > p2.price ? p1 : p2)
.ifPresent(System.out: :println);
What is the result?
PDF + Testing Engine |
---|
$57.75 |
Testing Engine |
---|
$43.75 |
PDF (Q&A) |
---|
$36.75 |
Oracle Free Exams |
---|
|