Juan Pablo Barale

Greenhorn
+ Follow
since Aug 27, 2018
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Juan Pablo Barale

In page 136, Table 3.5. the Description column for the "void push(E e)" method row should say: Adds an element to the front of the queue or throws an exception.
Is the same case as in the "boolean add(E e)" method description, in both cases a NullPointerException is thrown if the specified element is null.

Regards,
Hi @Kabi, you can do something like this:

You need to print n lines, all with the same length:
n-1 blanks + 1 #
n-2 blanks + 2 #
.
.
.
n-(n-1) blanks + n-1 #
0 blanks + n #

hope this helps
6 years ago
If a class is implementing two interfaces with the same default method (firm), the class doesn't know which implementation to use, so you are forced to override it in order to compile.
The same problem occurs in the case an interface extends two interfaces with the same default method.
84. What is the output of the following application?

Answer:
   D. One line of code does not compile.

But the answer should be:
   E. Two lines of code do not compile.
MyElectricBass class is also inheriting the problem from the ElectricBass class.
By compiling this code we can see the 2 compilation errors showing up:

Regards,
Ok, got it, but I think the second option is not so "going through the branches". I mean, it's just updating the conflictive lines, and if you are trying to use a native value in a supplier (Supplier<double>) you know you should be using a DoubleSupplier.

I will take the implication of the minimum from now on.

Thanks!
There are two possible solutions for question 56 in the OCP Practice Exam.

Question:
56. How many changes do you need to make in order for this code to compile?


A. None
B. One
C. Two
D. Three
E. Four

Answer:
C. First, a method reference uses two colons, so it should be Ready::getNumber. Second, you can’t use generics with a primitive, so it should be Supplier<Double>. The rest of the code is correct, so Option C is correct.

The answer is correct, but there's another way to solve this by making three changes, making answer D also possible and correct:
First, a method reference uses two colons, so it should be Ready::getNumber. Second, you can’t use generics with a primitive, so it should be DoubleSupplier. Third, you need to replace the get() method by the getAsDouble() method defined in the DoubleSupplier interface.

I think these changes should also be considered or the question should be updated to ask for the minimum changes required.

Thanks!
JP
In section Understanding Views (page 484), when introducing the methods Files.readAttributes() and Files.getFileAttributeView() the third paragraph starts with:

Both of these methods can throw a checked IOException, such as when the view class type is unsupported.



But only the Files.readAttributes() method can throw an Exception. The Files.getFileAttributeView() returns null when the view class type is not supported.