This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes R&H bouns1-49 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "R&H bouns1-49" Watch "R&H bouns1-49" New topic

R&H bouns1-49

nan sh
Ranch Hand

Joined: Jan 05, 2001
Posts: 167
Consider the following class definition:
public class Parent{
final void zzz(){}
Which of the following methods may appear in a subclass
of Parent, when the subclass is in a different package
from Parent? choose all correct options.
A) void zzz(){}
B) void zzz(int j){}
c) final void zzz(float f){}
D) public final void zzz(double d){}
The Answer was given as B,C,D
I wonder, as void zzz() in Parent can not be seen
in subclass, why subclass can not have another void zzz()?
what about take away final acess modifier in Parent class?
Anyone could explain?

Have you tried this Mock Exam Testing Engine yet?<br /><a href="" target="_blank" rel="nofollow"></a>
sai challa
Ranch Hand

Joined: Feb 06, 2001
Posts: 54
The final keyword in a method declaration indicates to the compiler that the method cannot be overridden by
subclasses.Hence choice A is incorrect.
If you take away the final access modifier from the method i think all A,B,C,D would be valid choices.
preeti dengri
Ranch Hand

Joined: Nov 30, 2000
Posts: 111
hi nan,
what is this R&h1-49 ??are these some kind of sample Q&A or a mock?please tell
thank you
Keith Green

Joined: Mar 30, 2001
Posts: 1
I think A is a correct answer - I tried this out and it will compile.
Nan's point is valid - the method has 'default' access and so will not be visible to subclasses in a different package. So declaring a method with the same signature in the subclass should be OK - it does not actually override the parent's method, since this will not have been inherited.
nan sh
Ranch Hand

Joined: Jan 05, 2001
Posts: 167
This question from R&H book( our Bible!). There are three Bouns Mock tests and one final test. The question is from Bonus 1 q49.
nan sh
Ranch Hand

Joined: Jan 05, 2001
Posts: 167
I have run the following code, it print out
"in B zzz", that means given answer is wrong!
Moderator, could you move this thread to Mock Exam errata forum please.
import pack1.*;
public class B extends A{
void zzz(){System.out.println("in B void zzz");}
public static void main(String[] args){
A a = new B();
B b = new B();
A a1 = new A();
// a.zzz(); compile error
// a1.zzz(); compile error

//package pack1;
package pack1;
class A{
final void zzz(){System.out.println("in A void zzz"); }
preeti dengri
Ranch Hand

Joined: Nov 30, 2000
Posts: 111
hi nan,
that's a good catch! keep it up.
i have got RHE book but the cd alongwith doesnot contain the three bonus mock tests and one final test u are talking if possible cud u please mail me all those at
thank you
nachiket deshpande
Ranch Hand

Joined: Oct 06, 2000
Posts: 114
i have the CD with bunus ques. but i am not able to run the tests.after some questions(5 or so) my machine hangs up!what's the problem.i have loaded them and then tried but same problem is coming?is it something to do with my machine?
please help.
preeti dengri
Ranch Hand

Joined: Nov 30, 2000
Posts: 111
hi all,
i have got the older version of RHE so i need ur help .please if possible,mail me the all three mock tests and a final test given with RHE latest edition at
waiting for an early reply
thank you
Consider Paul's rocket mass heater.
subject: R&H bouns1-49
Similar Threads
RHE mock question bonus1 q49
R&H bonus1 q49
Package and Overriding
from RHE Bonus Questions
RHE Bonus1 Q49