File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Mock Exam Errata and the fly likes R&H bonus1 q49 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 » Mock Exam Errata
Bookmark "R&H bonus1 q49" Watch "R&H bonus1 q49" New topic
Author

R&H bonus1 q49

nan s
Greenhorn

Joined: Dec 28, 2000
Posts: 16
Question:
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?
a) void zzz{}
b) void zzz(int j){}
c) final void zzz(float f){}
d) public final void zzz(double d){}
they have Answer is b,c,d
But I wonder subclass is in different package with Parent,
so subclass can not see final void zzz() in Parent,
because zzz() is "default", so i think there is no overridding here.
where i am wrong?
rajani peddi
Ranch Hand

Joined: Nov 27, 2000
Posts: 73
nan ,
The answers are correct and your understanding is also correct.
First of all option a) is wrong because it is neither a valid method nor a variable.
Now Since the method zzz() in superclass has package visibility it is not known to its subclass which is in another package. So the methods in subclass can neither overload nor override. Hence the subclass can have any valid method. Infact it can also have final void zzz() {}.
Hope this clears
rajani

[This message has been edited by rajani peddi (edited January 05, 2001).]
nan s
Greenhorn

Joined: Dec 28, 2000
Posts: 16
Sorry rajani and all,
I have a typing error about this bloody "a) void zzz{}", i checked again, IT IS "void zzz(){}", and their explanation of why "a" is incorrect as: "A final method may not be overridden, thus A is illegal."
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?
a) void zzz(){}
b) void zzz(int j){}
c) final void zzz(float f){}
d) public final void zzz(double d){}
they have Answer is b,c,d
i am sorry for error.
nan
nan s
Greenhorn

Joined: Dec 28, 2000
Posts: 16
Sorry rajani and all,
I have a typing error about this "a) void zzz{}", i checked again, IT IS "void zzz(){}", and their explanation of why a is incorrect as: "A final method may not be overridden, thus A is illegal."
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?
a) void zzz(){}
b) void zzz(int j){}
c) final void zzz(float f){}
d) public final void zzz(double d){}
they have Answer is b,c,d
i am sorry for error.
nan
nan sh
Ranch Hand

Joined: Jan 05, 2001
Posts: 167
Sorry rajani and all,
I have a typing error about this "a) void zzz{}", i checked again, IT IS "void zzz(){}", and their explanation of why a is incorrect as:"A final method may not be overridden, thus A is illegal."
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?
a) void zzz(){}
b) void zzz(int j){}
c) final void zzz(float f){}
d) public final void zzz(double d){}
they have Answer is b,c,d
i am sorry for error.
nan

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>
 
Don't get me started about those stupid light bulbs.
 
subject: R&H bonus1 q49
 
Similar Threads
RHE mock question bonus1 q49
Package and Overriding
from RHE Bonus Questions
RHE Bonus1 Q49
R&H bouns1-49