Given :
(Choose three.)
11. public interface Status {
12. /* insert code here */ int MY_VALUE = 10;
13. }
A. final
B. static
C. native
D. public
E. private
F. abstract
G. protected
Answer: A,B,D
While declaring any constant the variable name must be All Capitals .In the above question MY_VALUE is marked as final and therefore once 10 is assigned to it we can't change or alter its value again.
Therefore public static final int MY_VALUE = 10; is a correct syntax for declaring Constant and public static final are the three correct options .
(Choose three.)
11. public interface Status {
12. /* insert code here */ int MY_VALUE = 10;
13. }
A. final
B. static
C. native
D. public
E. private
F. abstract
G. protected
Answer: A,B,D
Explanation :
An interface by default 100% abstract ,So while declaring any method by default compiler implicitly adds abstract keyword in the method header and while declaring any variable or constant by default compiler implicitly adds public static final .While declaring any constant the variable name must be All Capitals .In the above question MY_VALUE is marked as final and therefore once 10 is assigned to it we can't change or alter its value again.
Therefore public static final int MY_VALUE = 10; is a correct syntax for declaring Constant and public static final are the three correct options .
0 comments:
Post a Comment