Answers to Assessment Test
-
B. The code compiles successfully, so options D and E are incorrect. The value of a cannot be changed by the addToInt() method, no matter what the method does, because only a copy of the variable is passed into the parameter x. Therefore, a does not change, and the output on line 9 is 15. For more information, see Chapter 7.
-
C, D, E. The program contains three compiler errors. First, the method getTailLength() in the interface HasTail is implicitly to be public, since it is an abstract interface method. Therefore, line 3 does not compile since it is an invalid override, reducing the visibility of the method, making option C correct. Next, the class Cougar implements an overloaded version of getTailLength() ...
Get OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.