Java OCA OCP Practice Question 790

Question

Which of the following are valid declarations inside an interface?

Select 2 options

  • A. void m ();
  • B. public void m ();
  • C. public final void m ();
  • D. static void m ();
  • E. protected void m ();


Correct Options are  : A B

Note

For Option A. void m ();

All interface methods have to be public.

No access control keyword in the method declaration also means public in an interface.

The absence of access control keyword in the method declaration in a class means package protected.

For Option C. public final void m ();

final is not allowed.

For Option D. static void m ();

static is not allowed.

For Option E.

All interface methods have to be public.




PreviousNext

Related