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 |
What is the synonym of string?
Why we go for collections in java?
How many bits is a double?
What are annotations in java?
What are the Class Libraries ?
Is it possible to do method overloading and overriding at a time
What is meant by class loader? How many types are there? When will we use them?
What is static synchronization?
What is java full form?
Mention the default values of all the elements of an array defined as an instance variable.
what is object slice?
Which collection allows duplicate values in java?