Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question 3 in Assessment Test -> page (xxxi)  RSS feed

 
Omar Abu Khamseh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dears,
What is the final answer to Question 3 in Assessment Test? page (xxxi)

C and D OR C,D and E

I'm confused
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Your question is difficult to answer, because we do not know about which assessment test it is. Can you explain which assessment test, and what exactly the question is?
 
Omar Abu Khamseh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question  Question 3 in Assessment Test -> page (xxxi) OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide
Exam 1Z0-808
Jeanne Boyarsky
Scott Selikoff

I apologize for not explaining well


 
Ralph van Delft
Greenhorn
Posts: 11
Angular Framework Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell us more about why you are confused?

Why do you think it should be C & D?
And why C,D & E?

Most of the time (in my case) it helps to write it all out. In that way you will learn the most.
 
Omar Abu Khamseh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer in the book is C(line#3 ) and  D(line#5), but when running same code in NetBeans given 3 compilation errors line#3 (C), line#5 (D), and  line #7 (E)

C, D, E. First, the method getTailLength() in the interface HasTail is assumed to be
public, since it is part of an interface. The implementation of the method on line 3 is
therefore an invalid override, as protected is a more restrictive access modifier than
public, so option C is correct. 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. Option E is incorrect(Here I'm confused), since Puma is marked
abstract and cannot be instantiated. The overloaded method on line 11 is declared
correctly, so option F is not correct. Finally, as the code has multiple compiler errors,
options A, B, and G can be eliminated. For more information, see Chapter 5.

 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could get more help if you posted the question itself as well. Since I don't have the book, I won't be able to help you right now.
 
Omar Abu Khamseh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the question is :


Q3. What is the output of the following code? (Choose all that apply)

A. 2
B. 4
C. The code will not compile because of line 3.
D. The code will not compile because of line 5.
E. The code will not compile because of line 7.
F. The code will not compile because of line 11.
G. The output cannot be determined from the code provided.
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks like an error in the book (which can happen sometimes of course). This is in fact mentioned in the errata, which should be available at http://selikoff.net/ocp but that's currently unavailable to me. I found http://eu.wiley.com/WileyCDA/WileyTitle/productCd-1118957407,miniSiteCd-SYBEX.html which mentions it:
In Point number 3:
'Puma is invalid' should be 'Cougar is invalid' for the explanation for D

'E is incorrect' should be 'E is correct'

I'm not sure how official this list is though; Jeanne, Scott, can you confirm that this is indeed an error in the book?
 
Omar Abu Khamseh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Errata have been corrected and Q#3  had become :

The answer is correct. In the explanation, “Puma is invalid” should be “Cougar is invalid” for the explanation for D. And “E is incorrect” should be “E is correct”. In the second printing, we introduced a regression error. It should be “since the declaration in the parent class Puma is invalid” and then “the declaration of Puma is invalid”


Thank you all and best regards
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!