private class A { void kani() System.out.printl,
March 10, 2007 at 8:26 AM

private class A
void kani()
public class B extends A
void valavan()
class C
public static void main(String args[])
A a=new A();
B b=new B();
i was not able to run this program.when i ru n this program some error appear.can u tell me what mistake i made and then what is difference between public , private,protected and default,

Posted by kanivalavn on Tuesday, 01.30.07 @ 15:08pm | #4695

Here in this case of a writting a class we have some rules in using our access modifiers

to give a brief idea abt it.......
We have 3 access modifiers in java and 4 access levels
(ie)private,protected,public r the three access modifiers in java
and private,public,protected,and default r four access levels in java

and the rules in using this access modifiers in java are ...

1)We should not use access modifier private and protected infront of class declaration, so if we use this we can not compile the program

This might be the solution for ur program not compiling

if u have any doubt regarding this issue u can feel free for mailing me

View All Comments | View Tutorial
Related Tutorial and Articles


If you enjoyed this post then why not add us on Google+? Add us to your Circles