|
-
Mar 26th, 2004, 10:03 AM
#1
Thread Starter
Lively Member
Interface Errors(Weaker Access Privileges )
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|