| Author |
regarding abstract
|
rajesh ssh
Greenhorn
Joined: Aug 23, 2006
Posts: 11
|
|
public abstract class Test { private int i=900; public class TestChild { public void method() { System.out.println(i);//here 'i' can access like wise // if i have private abstract void method in the Test then that also by extending i can implement it ..? } } // My Query is if Test class has private abstract void method(); then the inner class by extending that can implement body to that right ? [ April 30, 2008: Message edited by: rajesh ssh ]
|
Regards<br />RAJESH.M
|
 |
Stevi Deter
Ranch Hand
Joined: Mar 22, 2008
Posts: 265
|
|
Rajesh, Per the Java Language Specification, it's a compile time error for a private method to be declared abstract. It's impossible for a subclass to override a private method, because private methods are not inherited by subclasses. As a side note, please post your code within the UBB Code tags for readability. Thanks! [ April 30, 2008: Message edited by: Stevi Deter ]
|
There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
|
 |
rajesh ssh
Greenhorn
Joined: Aug 23, 2006
Posts: 11
|
|
hi,coulu you please tell public class Test { private int i=900; private void method() { return; } public class TestChild extends Test { public void method1() { super.method(); } } } } here private method can access in the sub class TestChild also..right ?
|
 |
rajesh ssh
Greenhorn
Joined: Aug 23, 2006
Posts: 11
|
|
yes,you are correct i understand in the last post i just called the method but i have not overriden.we cannot override private methods , Thank you
|
 |
Mintoo kumar
Ranch Hand
Joined: Aug 21, 2007
Posts: 61
|
|
You have declared a child class as inner class.As per JAVA ,inner class has no self existence ,it's scope is limited to the declared class.Therefore it can access private(public ,protected) members of outer class.Just check the class file name of this class.it will be like "Parent$Child.class" ,separated by "$". About "private abstract retrunType someMethod()" , already good explanation posted above.I would like to add only that in my opinion "private" and "abstract" is contradictory.Private is just to hide something and abstract give you the facility to someone to write on implementation(to exhibit).There language of creator did not allow us to write "private abstract" simultaneosly.
|
 |
 |
|
|
subject: regarding abstract
|
|
|