Home Tutorialhelp Comment private class A { void kani() System.out.printl

 
 

Comment

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

private class A
{
void kani()
System.out.println("kani");
}
public class B extends A
{
void valavan()
System.out.println("valavan");
}
class C
{
public static void main(String args[])
{
A a=new A();
B b=new B();
a.kani();
b.valavan();
}
}
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

mailid:naresh_madigani09@yahoo.co.in

View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Advertisements Advertisements
 

 

 

DMCA.com