QUESTION
Given:
11. public interface Status {
12. /* insert code here */ int MY_TRUE_VALUE = 10;
13. }
Which three are valid on line 12? (Choose three.)
A. final
B. static
C. native
D. public
E. private
F. abstract
G. protected
ANS - ABD
In Interfaces we can define constants for example:
interface you
{ int i=10;
}
now in interfaces every variable is implicitly public static final
Therefore, though we define int i=10 but for the compiler it is
public static final int i=10;
Now you can even define like this way :
- final int i=10;
- static int i=10;
- public int i=10;
- public static int i=10;
- public final int i=10;
- static final int i=10;
- public static final int i=10;
Invalid Declarations:
native - can be only applied to methods
private - variables in interfaces are public
protected - variables in interfaces are public
abstract - As the variables are implicitly final and we know final and abstract cannot be together, therefore it is invalid.
0 comments:
Post a Comment