prasadkowli80
Mar 26th, 2004, 09:03 AM
hello friends ,
i have written a simple java program .See the code below :
nterface A {
void test();
}
class B implements A {
void test() {
System.out.println(" i am in B ");
}
}//end of class B
class InterfaceDemo {
public static void main(String args[]) {
B ob = new B();
ob.test();
}
} // end of class InterfaceDemo
This program after compiling gives the following error :
" test() in B cannot implement test() in A; attempting to assign weaker access privileges; was public "
i know the solution is : --> "In the implementation, explicitly declare the implementing method as public"
But i dont know the reason behind it .......i want to know
" the method should be declared public "??????
Can please anybody clearly explain me in details ??
Thanx in advance ,
Prasad
i have written a simple java program .See the code below :
nterface A {
void test();
}
class B implements A {
void test() {
System.out.println(" i am in B ");
}
}//end of class B
class InterfaceDemo {
public static void main(String args[]) {
B ob = new B();
ob.test();
}
} // end of class InterfaceDemo
This program after compiling gives the following error :
" test() in B cannot implement test() in A; attempting to assign weaker access privileges; was public "
i know the solution is : --> "In the implementation, explicitly declare the implementing method as public"
But i dont know the reason behind it .......i want to know
" the method should be declared public "??????
Can please anybody clearly explain me in details ??
Thanx in advance ,
Prasad