Q) see the following code public class A { public stratic void main(String str[]) { } } class B extends A // (1) { // some code } if at (1) I put private the compiler says that package members should be accessible to the package members and if I put protected then it says that class or interface declaration expected but I think that they should be allowed as they are applied to class which does not contain main method what is the problem with that anyone ps explain me that ..
hai, The class which you are declaring as private is package level class, that can declared as public or default
<I> s.a.kugan</I>
Athiveera Kugan
Greenhorn
Joined: Mar 21, 2001
Posts: 15
posted
0
hai, The class which you are declaring as private is package level class, that can declared as only public or default .
Athiveera Kugan
Greenhorn
Joined: Mar 21, 2001
Posts: 15
posted
0
hai, The class which you are declaring as private is package level class, that can be declared as only public or default . <marquee>by s.a.kugan</marquee>
Athiveera Kugan
Greenhorn
Joined: Mar 21, 2001
Posts: 15
posted
0
hai, The class which you are declaring as private is package level class, that can be declared as only public or default . <marquee>by s.a.kugan</marquee>
hi It is not related with main method. main() is just a method compiler only complain when you want to run the class and tells there isnot any main() method described. A top level class can not have private or protocted modifiers! This is the rule. class A .... { public static void main... } class B extends A { } main method is inherited to class B you can run class B too.
-----------------------------------------------------<BR> Koray GUCLU ~ the sky has no limit ~<BR> (B.s. Computer Engineer)<BR> Frankfurt am Main, Germany<BR> web : <A HREF="http://www.geocities.com/korayguclu/<BR rel="nofollow">" TARGET=_blank>http://www.geocities.com/korayguclu/<BR></A> mail: korayguclu@yahoo.com<BR>-----------------------------------------------------
hello nishesh, u r a ranch hand. this means u have cleared SCJP.but u put up very basic questions on the board. i can't digest this.would u mind if i ask ur score on the test. kriti