Java Programming - Declarations and Access Control - Discussion

Discussion Forum : Declarations and Access Control - General Questions (Q.No. 18)
18.
Which is a valid declaration within an interface?
public static short stop = 23;
protected short stop = 23;
transient short stop = 23;
final void madness(short stop);
Answer: Option
Explanation:

(A) is valid interface declarations.

(B) and (C) are incorrect because interface variables cannot be either protected or transient. (D) is incorrect because interface methods cannot be final or static.

Discussion:
11 comments Page 2 of 2.

Bharath said:   1 decade ago
public static short stop=23; is given as correct answer but how come its possible, interface does not accept static modifiers?


Post your comments here:

Your comments will be displayed after verification.