Java Programming - Declarations and Access Control - Discussion
Read more: "Actions speak louder than words."
- (Proverb)
18.
Which is a valid declaration within an interface?
[A].
public static short stop = 23; [B].
protected short stop = 23; [C].
transient short stop = 23; [D].
final void madness(short stop);
Answer: Option D
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 .
Bharath said:
(Sat, Oct 16, 2010 12:34:31 PM)
public static short stop=23; is given as correct answer but how come its possible, interface does not accept static modifiers?
Hariom Singh said:
(Wed, Aug 3, 2011 11:33:53 PM)
What is the working of join method in threading ?
Pawan Patidar said:
(Wed, Nov 23, 2011 09:29:19 PM)
public static short stop=23; is given as correct answer but how come its possible, interface does not accept static modifiers?
Prabhat Kumar said:
(Fri, Dec 2, 2011 03:21:31 PM)
Option A is also wrong, because static methods r not allowed in interfaces.
Google said:
(Sun, Apr 14, 2013 09:15:21 PM)
Public static short stop=23; is given as correct answer but how come its possible, interface does not accept static modifier?