QUESTION 81
Given:
Book.java:
public class Book {
private String read(String bname) { return “Read” + bname }
}
EBook.java:
public class EBook extends Book {
public class String read (String url) { return “View” + url }
}
Test.java:
public class Test {
public static void main (String[] args) {
Book b1 = new Book();
b1.read(“Java Programing”);
Book b2 = new EBook();
b2.read(“http://ebook.com/ebook”);
}
}
What is the result?
A. Read Java Programming
View http:/ ebook.com/ebook
B. Read Java Programming
Read http:/ ebook.com/ebook
C. The EBook.java file fails to compile.
D. The Test.java file fails to compile.
Correct Answer: D
Section: (none)
ExplanationExplanation/Reference:
 
 
 
QUESTION 82
Given the code fragment:
ZonedDateTime depart = ZonedDateTime.of(2015, 1, 15, 3, 0, 0, 0, ZoneID.of
(“UTC-7”));
ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0, ZoneID.of
(“UTC-5”));
long hrs = ChronoUnit.HOURS.between(depart, arrive); //line n1
System.out.println(“Travel time is” + hrs + “hours”);
What is the result?
A. Travel time is 4 hours
B. Travel time is 6 hours
C. Travel time is 8 hours
D. An exception is thrown at line n1.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 83
Given the code fragment:
Path path1 = Paths.get(“/app/./sys/”);
Path res1 = path1.resolve(“log”);
Path path2 = Paths.get(“/server/exe/”);
Path res1 = path1.resolve(“/readme/”);
System.out.println(res1);
System.out.println(res2);
What is the result?
A. /app/sys/log
/readme/server/exe
B. /app/log/sys
/server/exe/readme
C. /app/./sys/log
/readme
D. /app/./sys/log
/server/exe/readme
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 84
Given the code fragment:
List<String> colors = Arrays.asList(“red”, “green”, “yellow”);
Predicate<String> test = n - > {
System.out.println(“Searching…”);
return n.contains(“red”);
};colors.stream()
.filter(c -> c.length() > 3)
.allMatch(test);
What is the result?
A. Searching...
B. Searching...
Searching...
C. Searching...
Searching...
Searching...
D. A compilation error occurs.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 85
Given:
class UserException extends Exception { }
class AgeOutOfLimitException extends UserException { }
and the code fragment:
class App {
public void doRegister(String name, int age)
throws UserException, AgeOutOfLimitException {
if (name.length () < 6) {
throw new UserException ();
} else if (age >= 60) {
throw new AgeOutOfLimitException ();
} else {
System.out.println(“User is registered.”);
}
}
public static void main(String[ ] args) throws UserException {
App t = new App ();
t.doRegister(“Mathew”, 60);
}
}
What is the result?
A. User is registered.
B. An AgeOutOfLimitException is thrown.
C. A UserException is thrown.
D. A compilation error occurs in the main method.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 86
Given the code fragment:
SCJP刷题笔记(Part nine)
What is the result?
A. 5 : 3 : 6
B. 6 : 5 : 6
C. 3 : 3 : 4
D. 4 : 4 : 4
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 87
Given:
SCJP刷题笔记(Part nine)
and the code fragment:
SCJP刷题笔记(Part nine)
Which modification enables the code fragment to print Speaker?
A. Implement Predicate in the Product.ProductFilter class and replace line n2 with .filter
(p -> p.ProductFilter.test (p))
B. Replace line n1 with:
public static boolean isAvailable (Product p) {
C. Replace line n2 with:
.filter (p -> p.ProductFilter: :isAvailable (p))
D. Replace line n2 with:
.filter (p -> Product: :ProductFilter: :isAvailable ())
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 88
Given the content:
SCJP刷题笔记(Part nine)
and the code fragment:
SCJP刷题笔记(Part nine)
What is the result?
A. username = Entrez le nom d’utilisateur
password = Entrez le mot de passe
B. username = Enter User Name
password = Enter Password
C. A compilation error occurs.
D. The program prints nothing.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 89
Given:
SCJP刷题笔记(Part nine)
What is the result?
A. –catch-
-finally-
-dostuff
B. –catch
C. –finally-
-catch
D. –finally
-dostuff-
-catch
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
SCJP刷题笔记(Part nine)
 
 
 
QUESTION 90
Given:
SCJP刷题笔记(Part nine)
What is the result?
A. Bar Hello
Foo Hello
B. Bar Hello
Baz Hello
C. Baz Hello
D. A compilation error occurs in the Daze class.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:

相关文章: