Declarations and Access Control

Q1:
Which three are valid method signatures in an interface?
  1. private int getArea();
  2. public float getVol(float x);
  3. public void main(String [] args);
  4. public static void main(String [] args);
  5. boolean setFlag(Boolean [] test);

A 1 and 2

B 2, 3 and 5

C 3, 4, and 5

D 2 and 4

ANS:B - 2, 3 and 5

(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.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.