Java OCA OCP Practice Question 1394

Question

Which one of these is a proper definition of a class Main that cannot be sub-classed?

Select 1 option

  • A. final class Main { }
  • B. abstract class Main { }
  • C. native class Main { }
  • D. static class Main { }
  • E. private class Main { }


Correct Option is  : A

Note

A final class cannot be subclassed.

Although declaring a method static usually implies that it is final, this is not true for classes.

An inner class can be declared static and still be extended.

For classes, final means it cannot be extended, while for methods, final means it cannot be overridden in a subclass.

The native keyword can only be used on methods, not on classes and or variables.




PreviousNext

Related