QUESTION 121
Given:
SCJP刷题学习笔记(Part thirteen)
and the code fragment:
SCJP刷题学习笔记(Part thirteen)
What is the result?
A. An exception is thrown at line n2.
B. 100
C. A compilation error occurs because the try block is declared without a catch or finally block.
D. A compilation error occurs at line n1.
Correct Answer: B
Section: (none)Explanation
Explanation/Reference:
 
 
 
QUESTION 122
Which two methods from the java.util.stream.Stream interface perform a reduction operation?
(Choose two.)
A. count ()
B. collect ()
C. distinct ()
D. peek ()
E. filter ()
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html
 
 
 
QUESTION 123
Which code fragment is required to load a JDBC 3.0 driver?
A. Connection con = Connection.getDriver
(“jdbc:xyzdata://localhost:3306/EmployeeDB”);
B. Class.forName(“org.xyzdata.jdbc.NetworkDriver”);
C. Connection con = DriverManager.getConnection
(“jdbc:xyzdata://localhost:3306/EmployeeDB”);
D. DriverManager.loadDriver (“org.xyzdata.jdbc.NetworkDriver”);
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 124
Given:
SCJP刷题学习笔记(Part thirteen)
Which option fails?
A. Foo<String, Integer> mark = new Foo<String, Integer> (“Steve”, 100);
B. Foo<String, String> pair = Foo.<String>twice (“Hello World!”);
C. Foo<Object, Object> percentage = new Foo<String, Integer>(“Steve”, 100);
D. Foo<String, String> grade = new Foo <> (“John”, “A”);Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 125
Given the code fragment:
SCJP刷题学习笔记(Part thirteen)
Which modification enables the code to print Price 5 New Price 4?
A. Replace line n2 with .map (n -> System.out.println (“New Price” + n –1)) and
remove line n3
B. Replace line n2 with .mapToInt (n -> n – 1);
C. Replace line n1 with .forEach (e -> System.out.print (“Price” + e))
D. Replace line n3 with .forEach (n -> System.out.println (“New Price” + n));
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 126
Given the definition of the Book class:
SCJP刷题学习笔记(Part thirteen)
Which statement is true about the Book class?
A. It demonstrates encapsulation.
B. It is defined using the factory design pattern.
C. It is defined using the singleton design pattern.
D. It demonstrates polymorphism.
E. It is an immutable class.
Correct Answer: A
Section: (none)
ExplanationExplanation/Reference:
 
 
 
QUESTION 127
Given the code fragment:
SCJP刷题学习笔记(Part thirteen)
You have been asked to define the ProductCode class. The definition of the ProductCode class must
allow c1 instantiation to succeed and cause a compilation error on c2 instantiation.
Which definition of ProductCode meets the requirement?
SCJP刷题学习笔记(Part thirteen)
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 128
Given the code fragment:
SCJP刷题学习笔记(Part thirteen)
Which statement can be inserted into line n1 to print 1,2; 1,10; 2,20;?
A. BiConsumer<Integer,Integer> c = (i, j) -> {System.out.print (i + “,” + j+
“; “);};
B. BiFunction<Integer, Integer, String> c = (i, j) –> {System.out.print (i + “,”
+ j+ “; “)};
C. BiConsumer<Integer, Integer, String> c = (i, j) –> {System.out.print (i + “,”
+ j+ “; “)};D. BiConsumer<Integer, Integer, Integer> c = (i, j) –> {System.out.print (i +
“,” + j+ “; “);};
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Reference: https://www.concretepage.com/java/jdk-8/java-8-biconsumer-bifunction-bipredicate-example
 
 
 
QUESTION 129
Given the code fragment:
SCJP刷题学习笔记(Part thirteen)
What is the result?
A. Java EEJava EESE
B. Java EESE
C. The program prints either:
Java EEJava SE
or
Java SEJava EE
D. Java EEJava SE
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 130
Given the code fragments :
SCJP刷题学习笔记(Part thirteen)
and
SCJP刷题学习笔记(Part thirteen)
What is the result?
A. TV Price :110 Refrigerator Price :2100
B. A compilation error occurs.
C. TV Price :1000 Refrigerator Price :2000
D. The program prints nothing.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:

相关文章: