Forums Register Login

Query on Overriding

+Pie Number of slices to send: Send
When a method is overrided there is a restriction that the method in the sub class cannot be more restrictive than the original.

public void print() {} cannot be overrided to
protected void print() {}

But what about the default access specifier i.e "void print() {}" ?
+Pie Number of slices to send: Send
Hi,

Default is more restrictive then protected and less then private.
+Pie Number of slices to send: Send
So the it's like this

private --> default ---> protected --> public
+Pie Number of slices to send: Send
I assume the arrow (-->) means "is more restrictive than". If so, then you are correct.

Layne
[ February 24, 2005: Message edited by: Layne Lund ]
Right! We're on it! Let's get to work tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 591 times.
Similar Threads
Abstract Inner class
Doubts
How to disable copy and paste in a JTextField
overriding , Hiding
Overriding private method
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 13:53:42.