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 |
Why is a string immutable?
What is token in java?
What is the best way to findout the time/memory consuming process?
define System.out.println(); what is the meaning!
Why java uses the concept of the string literal?
Is alive and join method in java?
Can a private method be declared as static?
GoldMansachs Interview process....
What is casting?
What are bind parameters?
Can a constructor have different name than a class name in java?
What is math exp in java?