Given:
class Student {
String course, name, city;
public Student (String name, String course, String city) {
this.course = course; this.name = name; this.city = city;
}
public String toString() {
return course + : + name + : + city;
}
public String getCourse() {return course;}
public String getName() {return name;}
public String getCity() {return city;}
and the code fragment:
List<Student> stds = Arrays.asList(
new Student (Jessy, Java ME, Chicago),
new Student (Helen, Java EE, Houston),
new Student (Mark, Java ME, Chicago));
stds.stream()
.collect(Collectors.groupingBy(Student::getCourse))
.forEach(src, res) -> System.out.println(scr));
What is the result?
B
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<Product> products = new ArrayList <> (Arrays.asList(new Product(1, 10),
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?
C
Given the code fragment:
List<Double> doubles = Arrays.asList (100.12, 200.32);
DoubleFunction funD = d > d + 100.0;
doubles.stream (). forEach (funD); // line n1
doubles.stream(). forEach(e > System.out.println(e)); // line n2
What is the result?
A
Explanation:
Given the code fragments:
class ThreadRunner implements Runnable {
public void run () { System.out.print (Runnable) ; }
}
class ThreadCaller implements Callable {
Public String call () throws Exception {return Callable; )
}
and
ExecutorService es = Executors.newCachedThreadPool ();
Runnable r1 = new ThreadRunner ();
Callable c1 = new ThreadCaller ();
// line n1
es.shutdown();
Which code fragment can be inserted at line n1 to start r1 and c1 threads?
D
Given the definition of the Employee class:
and this code fragment:
What is the result?
A
Given:
From what threading problem does the program suffer?
B
Given:
and the code fragment:
What is the result?
D
Explanation:
Given that data.txt and alldata.txt are accessible, and the code fragment:
What is required at line n1 to enable the code to overwrite alldata.txt with data.txt?
D
What is true about the java.sql.Statement interface?
D
Given the code fragments:
and
What is the result?
C
Given the structure of the Student table:
Student (id INTEGER, name VARCHAR)
Given the records from the STUDENT table:
Given the code fragment:
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWord exists.
What is the result?
B
Given the code fragment:
Which should be inserted into line n1 to print Average = 2.5?
C
Which two statements are true about synchronization and locks? (Choose two.)
A,B
Which two statements are true about the Fork/Join Framework? (Choose two.)
A,C
Given the code fragment:
Which code fragment, when inserted at line 7, enables printing 100?
A