Access specifier of methods in interfaces
In Java, all methods in an interface are public even if we do not specify public with method names. Also, data fields are public static final even if we do not mention it with fields names. Therefore, data fields must be initialized.
Consider the following example, x is by default public static final and foo() is public even if there are no specifiers.
interface Test {
int x = 10 ;
void foo();
}
|
Last Updated :
07 Dec, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...