QUESTION 61
Given:
public interface Moveable {
public default void walk (Integer distance) {System.out.println
("Walking");}
public void run(Integer distance);
}
Which statement is true?
A.
Moveable
can be used as below:
Moveable animal = n - > System.out.println(“Running” + n);
animal.run(100);
animal.walk(20);
B.
Moveable
can be used as below:
Moveable animal = n - > n + 10;
animal.run(100);
animal.walk(20);
C.
Moveable
can be used as below:
Moveable animal = (Integer n) - > System.out.println(n);
animal.run(100);
Moveable.walk(20);
D.
Movable
cannot be used in a lambda expression.
Correct Answer:
A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 62
Which two code blocks correctly initialize a Locale variable? (Choose two.)
A.
Locale loc1 = "UK";
B.
Locale loc2 = Locale.getInstance("ru");
C.
Locale loc3 = Locale.getLocaleFactory("RU");
D.
Locale loc4 = Locale.UK;
E.
Locale loc5 = new Locale ("ru", "RU");
Correct Answer:
DE
Section: (none)
Explanation
Explanation/Reference:
QUESTION 63
Given:
class FuelNotAvailException extends Exception { }
class Vehicle {
void ride() throws FuelNotAvailException { //line n1
System.out.println(“Happy Journey!”);
}
}
class SolarVehicle extends Vehicle {
public void ride () throws Exception { //line n2
super.ride ();
}
}
and the code fragment:
public static void main (String[] args) throws FuelNotAvailException, Exception
{
Vehicle v = new SolarVehicle ();
v.ride();
}
Which modification enables the code fragment to print
Happy Journey!
?
A. Replace
line n1
with
public void ride() throws FuelNotAvailException {
B. Replace
line n1
with
protected void ride() throws Exception {
C. Replace
line n2
with
void ride() throws Exception {
D. Replace
line n2
with
private void ride() throws FuelNotAvailException {
Correct Answer:
B
Section: (none)
Explanation
Explanation/Reference:
抛出异常、自定义异常:
https://blog.csdn.net/qq_18505715/article/details/73196421
QUESTION 64
Given the definition of the
Emp
class:
public class Emp
{
private String eName;
private Integer eAge;
Emp(String eN, Integer eA) {
this.eName = eN;
this.eAge = eA;
}
public Integer getEAge () {return eAge;}
public String getEName () {return eName;}
}
and code fragment:
Listli = Arrays.asList(new Emp("Sam", 20), new Emp("John", 60), new Emp
("Jim", 51));
Predicate agVal = s -> s.getEAge() > 50; //line n1
li = li.stream().filter(agVal).collect(Collectors.toList());
Stream names = li.stream().map(Emp::getEName); //line n2
names.forEach(n -> System.out.print(n + " " ));
What is the result?
A.
Sam John Jim
B.
John Jim
C. A compilation error occurs at
line n1
.
D. A compilation error occurs at
line n2
.
Correct Answer:
B
Section: (none)
Explanation
Explanation/Reference:
Part three 涉及到的Predicate函数:
https://blog.csdn.net/qq_27416233/article/details/83418791
Part one 涉及到的
Arrays.asList说明:
https://blog.csdn.net/chenleixing/article/details/43775127
Part two 涉及到的Stream语法:https://blog.csdn.net/SeanTandol/article/details/86630437
QUESTION 65
For which three objects must a vendor provide implementations in its JDBC driver? (Choose three.)
A.
Time
B.
Date
C.
Statement
D.
ResultSet
E.
Connection
F.
SQLException
G.
DriverManager
Correct Answer:
CDE
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Database vendors support JDBC through the JDBC driver interface or through the ODBC connection. Each
driver must provide implementations of java.sql.Connection, java.sql.Statement,
java.sql.PreparedStatement, java.sql.CallableStatement, and java.sql.Re sultSet. They must also
implement the java.sql.Driver interface for use by the generic java.sql.DriverManager interface.
QUESTION 66
Given the code fragment:
LocalDate valentinesDay =LocalDate.of(2015, Month.FEBRUARY, 14);
LocalDate nextYear = valentinesDay.plusYears(1);
nextYear.plusDays(15); //line n1
System.out.println(nextYear);
What is the result?
A. 2016-02-14
B. A
DateTimeException
is thrown.
C. 2016-02-29
D. A compilation error occurs at
line n1
.
Correct Answer:
A
Section: (none)
Explanation
Explanation/Reference:
LocalDate的使用:
https://blog.csdn.net/u011055819/article/details/80070429
QUESTION 67
Given the code fragment:
BiFunction val = (t1, t2) -> t1 + t2; //line n1
System.out.println(val.apply(10, 10.5));
What is the result?
A. 20
B. 20.5
C. A compilation error occurs at
line n1
.
D. A compilation error occurs at
line n2
.
Correct Answer:
C
Section: (none)
Explanation
error:Type mismatch: cannot convert from double to Integer
Explanation/Reference:
BiFunction说明:
https://blog.csdn.net/u014331288/article/details/76319219
QUESTION 68
Which statement is true about
java.time.Duration
?
A. It tracks time zones.
B. It preserves daylight saving time.
C. It defines time-based values.
D. It defines date-based values.
Correct Answer:
C
Section: (none)
Explanation
Explanation/Reference:
Reference:
http://tutorials.jenkov.com/java-date-time/duration.html#accessing-the-time-of-a-duration
QUESTION 69
Given the code fragment:
UnaryOperator uo1 = s -> s*2; line n1
List loanValues = Arrays.asList(1000.0, 2000.0);
loanValues.stream()
.filter(lv -> lv >= 1500)
.map(lv -> uo1.apply(lv))
.forEach(s -> System.out.print(s + “ “));
What is the result?
A. 4000.0
B. 4000
C. A compilation error occurs at
line n1
.
D. A compilation error occurs at
line n2
.
Correct Answer:
D
Section: (none)
Explanation
error:Multiple markers at this line
- Cannot infer type argument(s) for map(Function)
- Line breakpoint:Test1 [line: 28] - main(String[])
Explanation/Reference:
QUESTION 70
You have been asked to create a ResourceBundle which uses a properties file to localize an application.
Which code example specifies valid keys of menu1 and menu2 with values of File Menu and View Menu?
A.
File Menu
View Menu
B.
menu1File Menu
menu2View Menu
C.
menu1, File Menu, menu2, View Menu
Menu
D.
menu1 = File Menu
menu2 = View Menu
Correct Answer:
D
Section: (none)
Explanation
Explanation/Reference:
