Java OCA OCP Practice Question 1457

Question

Which of the following are valid classes?

Select 1 option

A. public class A extends Number  { 
   } 
B. public class A extends Boolean  { 
   } 
C. public class A extends System  { 
   } 
D. public class A extends String  { 
   } 


Correct Option is  : A

Note

String, StringBuilder, and StringBuffer - all are final classes.

Wrapper classes for primitives (java.lang.Boolean, java.lang.Integer, java.lang.Long, java.lang.Short etc.) are final and so they cannot be extended.

java.lang.Number, however, is not final.

Integer, Long, Double etc. extend Number.

java.lang.System is final as well.




PreviousNext

Related