Discussion :: Declarations and Access Control
-
Which three are valid method signatures in an interface?
- private int getArea();
- public float getVol(float x);
- public void main(String [] args);
- public static void main(String [] args);
- boolean setFlag(Boolean [] test);
Answer : Option B
Explanation :
(2), (3), and (5). These are all valid interface method signatures.
(1), is incorrect because an interface method must be public; if it is not explicitly declared public it will be made public implicitly. (4) is incorrect because interface methods cannot be static.
Be The First To Comment