Andrey Kotelnikov

Greenhorn
+ Follow
since Jan 06, 2021
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
3
In last 30 days
0
Total given
0
Likes
Total received
5
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Andrey Kotelnikov

Question in the book: Which statements about the following Twins class are true? (Choose three.)


Variants:
A. The class fails to compile because of the write() method.
B. The class fails to compile because of the publish() method.
C. The class fails to compile because of the think() method.
D. All of the methods defined in the Alex interface are accessible in the Twins class.
E. All of the methods defined in the Michael interface are accessible in the Twins class.
F. The Twins class cannot be marked abstract.

Answer in the book:  A, C, E
All of the interface methods without a private modifier are implicitly public. In a class, though, a method without a modifier is package-private by default. For this reason, the write() and think() methods do not compile because they are missing the public modifier, making options A and C correct. These are the only compiler errors, making option B incorrect. Option D is incorrect because the process() method is not accessible with Twins because it is private. Option E is correct, as all methods are accessible. Even the overridden default method can be accessed in the Twins class by calling Michael.super.write(). Finally, option F is incorrect as the class still compiles if it is marked abstract.


I think option E is incorrect. Method study() in Michael interface is private. It's not accessible from Twins class.
Answer starts with:
"D.   The default no‐argument instructor is inserted by the compiler whenever"

But should be "The default no‐argument CONSTRUCTOR is inserted by the compiler whenever"


Option D is a correct answer. But it says "The DesertTortoise interface does not compile."
It should be fixed to "The DesertTortoise CLASS does not compile."

Campbell Ritchie wrote:Does the question show a catch or a finally? Neither is absolutely necessary because this is a try with resources.



There are no catch or finally. They are not necessary here.
Eror is in option D description.
It says about some line with comment  //s2
But there is no line with such a comment in code. Though option D is not correct I think authors missed this comment (//s2) in code.
Option D says "The code does not compile due to line s2."

But in code there is no such line with a comment //s2

var url = "jdbc:derby:bunnies";
var sql = "INSERT INTO bunny(name, color) VALUES (?, ?)";
try (var conn = DriverManager.getConnection(url);
  var stmt = conn.prepareStatement(sql)) {  // s1

  stmt.setString(1, "Daisy");
  stmt.setString(2, "Brown");

  stmt.executeUpdate();

  stmt.setString(1, "Cinna");
  stmt.setString(2, "Brown");

  stmt.executeUpdate();
}
I've bought a book on Amazon "OCP Oracle Certified Professional Java SE 11 Developer Practice Tests"
That's a book full of tests.
In chapter 2, question #18 is:
""Which of the following statements compile and create infinite loops at runtime? (Choose two.)"
Variants are:
A. while (!false) {}
B. do {}
C. for( : ) {}
D. do {} while (true);
E. while {}
F. for( ; ; ) {}

Correct answer is A, D, F. So it's three options, not two as is asked.
In answeres to that book in Appendix correct answers are A, D, F

Task description is incorrect
In "Interactive Online Learning Environment and Test Bank" page on http://app.efficientlearning.com/ for book Java Practice Tests 11
I've chosen answer B (which is correct). But system says - correct answer is C. I've checked the book and correct answer is B
I've got print screen. Maybe others don't have this error.
I don't know how to report error in tests to efficientlearning.com

"Which of the following statements compile and create infinite loops at runtime? (Choose two.)"

Should be:
"Which of the following statements compile and create infinite loops at runtime? (Choose three.)"


There are three correct answeres
So, if I have Java 8 OCP - it's not proper to pass Upgrade exam now. It costs 245$
I can just pass 819-J exam for 25$
Am I right? I'd got the same Java 11 developer badge?
Thanks for reply