when asub class inherits a super class and overrides a
public method of super class in sub class(public method in
super class).
why these methods needs to be public in sub class.
(otherwise compile time error).
Answers were Sorted based on User's Feedback
Answer / imtiyaz
The access specifier for the overriding method can allow
more but not less access than the overridden method.
For example, a protected method in the superclass can be
made public but not private
private, protected and public is Ascending order of access
modifiers depending upon the strength
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / ravikiran
the access specifies sould not me more restrictive in a
subclass.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sushila
if super class method is public, then override method should
be public.
override method will take same access specifier or expanded one.
the order of access specifier is
private > default > protected > public
| Is This Answer Correct ? | 1 Yes | 0 No |
Can a class be defined inside an interface?
Why do we need public static void main(String args[]) method in Java...?
What if I write static public void instead of public static void in java?
What is integer valueof?
Is null an object java?
Do extraneous variables affect validity?
When abstract methods are used?
Explain public static void main(string args[]) in java.
What is a Transient Object?
0 Answers InfoAxon Technologies,
What is the difference between the jdk 1.02 event model and the event-delegation model introduced with jdk 1.1?
what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread
What is the top class of AWT event hierarchy?