Java OCA OCP Practice Question 1524

Question

Which of the following cannot include a static method in its definition?

  • A. Abstract class
  • B. Static nested class
  • C. Interface
  • D. Local inner class


D.

Note

Both abstract classes and interfaces can include static methods, so Options A and C are incorrect.

A static nested class can include static methods, but it is the only type of inner class in which this is allowed.

Local inner classes, anonymous inner classes, and member inner classes do not support static methods.

Option D is correct, and Option B is incorrect.




PreviousNext

Related