Artem Lovan

Greenhorn
+ Follow
since Aug 20, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 Artem Lovan

In book "Java OCP 8 Programmer II Study Guide", Chapter 2 exam, question 5,
answer F claims "Requires a public static  method to retrieve the instance of the singleton."

In my view, method can have static (default/package level) method access, so the singleton is for other classes within the same package, and it's too a proper singleton pattern since other classes can retrieve the instance of the singleton.

Many thanks in advance for your thoughts!  
That makes sense, thanks!

But now I have a follow up question on "Oracle announced that code snippets can be treated as ignoring thrown exceptions." Does it mean in code snippets where exception needs to be catches, we should be aware that there might now be any code that catches an exception but we shouldn't see it as incorrect code because Oracle announced it as "fine" for a code snippet? I would really appreciate an explanation since that of cause can play big role of what folks might select as correct answer on the exam.

Thanks!
In Question No. 3, for Chapter 9, the correct answer is presented as D only, though I agree with that I believe "B" is correct too since Files.readAttributes() throws checked IOException and the code snipped isn't catching it, therefore code won't compile on line 2 too.

Please correct if I'm missing the point, thanks!
Sorry about confusion regards "mock exam 2". One small thing, there is not "u" in my last name as shown on the errata .

Artem Lovan wrote:OCP Online Chapter 2 Test - Question No. 2 asks what the result is of the following code, and has a radio button to check an answer.

I'm referring to the book "OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide: Exam 1Z1-809"

An error that I see is that this code sample have code lines from 1 to 10, which means it's all one file.
Per file, in java, there can be only one "public" class/interface which results in compile error on line 4 and 5 as well, since the interface and abstract class are declared as "public".
Plus, line No.8 doesn't compile for two reasons, concrete class doesn't override abstract climb method (what makes E as correct answer based on the explanation), and it as well starts with "public"

Same errors for question No. 10.

Please correct if I'm off course, thanks!

Question No. 2 asks what the result is of the following code, and has a radio button to check an answer.

An error that I see is that this code sample have code lines from 1 to 10, which means it's all one file.
Per file, in java, there can be only one "public" class/interface which results in compile error on line 4 and 5 as well, since the interface and abstract class are declared as "public".
Plus, line No.8 doesn't compile for two reasons, concrete class doesn't override abstract climb method (what makes E as correct answer based on the explanation), and it as well starts with "public"

Please correct if I'm off course, thanks!
My understanding is that its not an option to handle or declare, it's always a requirement to either handle a checked exception or declare it.

But thinking about your post, it might be that I'm looking at "allowed to" from different angle as it was thought of in the explanation.. Thanks!
The answer for question No.18 claims the correct answer as A;B;C;D

A -> Checked exceptions are allowed to be handled or declared
B -> Checked exceptions are required to be handled or declared

Obviously it cant hold true for both. I didn't see this one on errata list (to my big surprise) therefor the topic.

If I'm not following the logic, much appreciation for explanation!
Answer C;D;E;F

C -> pollinate(1)) prints 3. That should be pollinate(1)
D -> pollinate(1)) prints 4. That should be again pollinate(1)
E -> pollinate("flower")) prints 5. That should be pollinate("flower")
F -> pollinate("flower")) prints 6. That should be pollinate("flower")
Answer gives A;C;D;F as correct answer.

Given that answer A is correct, which interface methods; they, can be declared abstract, static, or default.

Answer C seems wrong, following in the explanation "They ..." this "they" is again -> abstract, static, or default.
But if a static method is declared in an interface it can't be overridden since static method can only be hidden.

Please correct if I'm not following the logic.