aspose file tools*
The moose likes Associate Certification (SCJA,OCAJ 5/6) and the fly likes Wrong answer in SCJA Certification Guide Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Associate Certification (SCJA,OCAJ 5/6)
Bookmark "Wrong answer in SCJA Certification Guide" Watch "Wrong answer in SCJA Certification Guide" New topic
Author

Wrong answer in SCJA Certification Guide

Hussam Odeh
Ranch Hand

Joined: Jul 03, 2007
Posts: 55
Dear ranchers,

Today I noticed in the Certification book an error in Question 13 Page 333, it says that options (c) and (d) are correct, while option (c) is not correct because its more restrictive "like option (a)".

I have no idea if there was previous disscussion regarding this issue, but anyhow i noticed it while reading the book.

Any comments about this issue?

Thank you.


SCJA 1.0: 98%, SCJP 5.0: 97%, SCWCD 5.0: 100%
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
What is the question?


“Everything should be as simple as it is, but not simpler.” Albert Einstein
Hussam Odeh
Ranch Hand

Joined: Jul 03, 2007
Posts: 55


Which of the following pieces of code, placed on line xxx, would allow this class to successfully compile?

a) private String doIt() {return null;}
b) Object doIt(int i) {return null;}
c) Object doIt() {return null;}
d) public String doIt() {return null;}

Book's answer is "(c) and (d)", but actually (c) is not correct because its more restrictive.
sebastian tortschanoff
Ranch Hand

Joined: Mar 19, 2009
Posts: 68
Hmm,

so when you do this:



it works fine. Otherwise it won't work.


Power from within.

Failed SCJP 2 times :-(
Hussam Odeh
Ranch Hand

Joined: Jul 03, 2007
Posts: 55
The key point here is that when you declare a method inside an interface, it should be ALWAYS "public abstract" and when you declare a variable inside an interface, it should be ALWAYS "public static final", that means when you override any method from an interface, your overriding method should be public, otherwise it will not work because it will be more restrictive.
Larry Olson
Ranch Hand

Joined: Feb 03, 2009
Posts: 142
Hussam Odeh wrote:The key point here is that when you declare a method inside an interface, it should be ALWAYS "public abstract" and when you declare a variable inside an interface, it should be ALWAYS "public static final", that means when you override any method from an interface, your overriding method should be public, otherwise it will not work because it will be more restrictive.


True. A overriding method couldn't be more restrictive than the original method defined somewhere higher in the hierarchy, though it's return type could be a sub-type of the return type of the original method.

So in this case only
public String doIt() {return null;}

will work.
Hussam Odeh
Ranch Hand

Joined: Jul 03, 2007
Posts: 55
Larry Olson wrote: though it's return type could be a sub-type of the return type of the original method.


About the return type, what you said is true ONLY if we were talking about Java 5 or above, otherwise its not allowed.
Larry Olson
Ranch Hand

Joined: Feb 03, 2009
Posts: 142
Thanks for pointing that out. I wasn't aware of that since I was looking into 1.5+. Is it important to understand how 1.5+ is different from the previous versions if one is preparing for SCJP 1.6? Is that a worthwhile exercise?
Hussam Odeh
Ranch Hand

Joined: Jul 03, 2007
Posts: 55
Larry Olson wrote:Thanks for pointing that out. I wasn't aware of that since I was looking into 1.5+. Is it important to understand how 1.5+ is different from the previous versions if one is preparing for SCJP 1.6? Is that a worthwhile exercise?


I dont think it's necessary for the exam, but it's good to know about it.
Larry Olson
Ranch Hand

Joined: Feb 03, 2009
Posts: 142
Hi,

I have a basic question. Does SCJP exam include questions about Designing Graphical User Interfaces, you know GUI classes like Buttons, frames, layout managers, Swing components etc. etc.

Looking at the Sun SCJP objectives at http://www.sun.com/training/catalog/courses/CX-310-065.xml,
I don't seem to find any references to GUI classes at all. I am surprised. OR am I mis-reading something ?

Thanks.
Hussam Odeh
Ranch Hand

Joined: Jul 03, 2007
Posts: 55
Hi Larry,

No its not included in the SCJP exam, and you can see the differences between SCJP 5 and SCJP 6 in this url:

http://faq.javaranch.com/java/ScjpFaq#16diff15
 
jQuery in Action, 2nd edition
 
subject: Wrong answer in SCJA Certification Guide