File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "R&H bouns1-49" Watch "R&H bouns1-49" New topic
Author

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="http://www.mycgiserver.com/~nan111/index.html" target="_blank" rel="nofollow">www.mycgiserver.com/~nan111/index.html</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
Greenhorn

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.
//file B.java
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
b.zzz();
// 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 about.so if possible cud u please mail me all those at preetidengri@yahoo.com.
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 preetidengri@yahoo.com
waiting for an early reply
thank you
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: R&H bouns1-49
 
Similar Threads
from RHE Bonus Questions
Package and Overriding
RHE mock question bonus1 q49
RHE Bonus1 Q49
R&H bonus1 q49