Alan Couze

+ Follow
since Aug 03, 2015
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alan Couze

In chapter 2 on page 57 there is an example on the pre/post increment and decrement operators:

It explains that first, the x is incremented and returned:

However, on page 51, Table 2.1 it says that post-unary operators have higher precedence over pre-unary operators. So in this example why wouldn't the x be decremented to 2 first and return 3?

Then x would be incremented to 3

...and then x would be decremented back to 2:

This yields the same result that the book states, but just in a different manner. Which is correct?
In Chapter 1 it explains that the following import statement is not valid when you want to import java.nio.file.Files and java.nio.file.Paths:

However, I tried creating a couple of test packages and an import such as this seemed to work. For example, I created a Java class

And this code is located in directory test1/test2:

The example above does error out by saying " error: package test1 does not exist". However, if I add any Class to the test1 directory (i.e. "Test1") then the above compiles without error. So, it seems to me that the wildcard for imports will work correctly with sub-packages (i.e. test1.test2) but only if there are Classes in the parent package(s) (test1).

Is this a correct assumption?

I see what I did wrong. I missed the fact that the getTailLength(int) is an overloaded method - I missed the int parameter! Although at least the typos will be reported. Thanks.
There is a typo in the explanation of the Assessment test answer #4:

This should be

I'm either highly confused, or the answer key for Assessment question 3 is incorrect. It says that the answers are C, D, E.

I understand that 'C' is a correct answer, since there is an invalid override (more restrictive access modifier in the class is defined).

Answer 'D' does not seem to be a correct answer. The explanation says "Next, the class Cougar implements an overloaded version of getTailLength(), but since the declaration in the parent class Puma is invalid, it needs to implement a public version of the method. Since it does not, the declaration of Puma is invalid, so option D is correct." However, class Cougar does implement a public version of getTailLength().

'E' seems to be a correct answer, however the answer section says "Option E is incorrect, since Puma is marked abstract and cannot be instantiated." Shouldn't it say "Option E is correct"?

So I believe that C,E are correct answers, but D is not.