Hi Above,
Your quote,
just define the method test() as public
that must be sufficient....
By default, the method without any modifier has a default access which means it is accesible in that particular package by any class defined in the same package. So your answer of marking the method public is not the one I expected. I came across this question from a website,
# Assume that class A extends class B, which extends class C. Also all the three classes implement the method test(). How can a method in a class A invoke the test() method defined in class C (without creating a new instance of class C). Select the one correct answer.
1. test();
2. super.test();
3. super.super.test();
4. ::test();
5. C.test();
6. It is not possible to invoke test() method defined in C from a method in A.
The answer given was 6. But I feel it is 1. By the way what
"Also all the three classes implement the method test()" means from the question above?Did they mean Overriding??
I tried it using the code as below,
and I got the o/p, I'm from the top class. So answer option 1 is correct in the above mentioned question. Anyone corrections on this?
Regards,
Jothi Shankar Kumar. S
[ October 27, 2006: Message edited by: Jothi Shankar Kumar Sankararaj ]