[java ee programming] Re: Method Overriding Rules in Java

2010-10-18 Thread Sergey Nikiforov
Hi, All. Here is the sequence of java access levels: public->protected->default->private As public is the strongest so child's method can only be public. And it can throw only IOException or its subclasses or nothing at all. import java.io.IOException; class Farther{ public void FarthersMe

[java ee programming] Re: Method Overriding Rules in Java

2010-10-18 Thread Mayank Gupta
class Parent{ public void methodA(){ } } class Child{ private void methodA(){ //private method not possible so The access level *cannot be more restrictive* than the overridden method's access level. } } class Parent{ public void methodA() throws IOException{ } } class Child{ pub

Re: [java ee programming] Method Overriding Rules in Java

2010-10-18 Thread Chris K
The access level *cannot be more restrictive* than the overridden method's access level. However the access level *can be less restrictive* than the overridden method's access level. Here is an example: Lets say you are overriding: public void doSomething{} Well you cannot make it: private vo

[java ee programming] Re: Method Overriding Rules in Java

2010-10-18 Thread Jayesh
See the code explains. public class A { protected void test() throws Exception { System.out.println("in A"); } } public class B extends A { public void test() throws IOException { System.out.println("in B"); } } As

[java ee programming] Method Overriding Rules in Java

2010-10-18 Thread Nirmal Kumar
Hi All, Can anyone explain the following Method Overriding Rules in Java: The access level *cannot be more restrictive* than the overridden method's access level. However the access level *can be less restrictive* than the overridden method's access level. The overridden method should not throw