File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes from RHE Bonus Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "from RHE Bonus Questions" Watch "from RHE Bonus Questions" New topic

from RHE Bonus Questions

Sathi Chowdhury
Ranch Hand

Joined: Mar 16, 2001
Posts: 52
This is from Rhe book's bonus question set...
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) { }
I thought all are correct because since the subclass is out side the package so the zzz() method of parent is not accessible from the subclass.
but the answer is given B,C,D which are very obvious ,but i have a doubt that A also is correct...can anybody explain me the right thing
thank u
Daniel Dunleavy
Ranch Hand

Joined: Mar 13, 2001
Posts: 276
I should think it would be that final does not change what is returned or what is passed to method.
mousami bhattacharya
Ranch Hand

Joined: May 13, 2001
Posts: 40
I agree with you , even I thought it to be all options .
I checked out by writing the code.and we are correct.
If a subclass is in a different package ,then the default method in parent is not accessible to the subclass and we can provide the same method signature with a more restricting accesibility .It just gives a warnign during compile time.
So the answer should be all 4
Charlie Swanson
Ranch Hand

Joined: Jan 29, 2001
Posts: 213
I entered the below code and it ran fine. You are right about
option A.
package mypack1;
public class Parent {
final void zzz() {
package mypackage;
import mypack1.*;
public class Child extends Parent {
void zzz() {
System.out.println("child zzz");
public static void main(String args []) {
new Child().zzz();
I agree. Here's the link:
subject: from RHE Bonus Questions
It's not a secret anymore!