Java OCA OCP Practice Question 1588

Question

Consider the following class...

class MyString extends String{
   MyString (){ super ();  }
}

The above code will not compile.

Select 1 option

  • A. True
  • B. False


Correct Option is  : A

Note

This will not compile because String is a final class and final classes cannot be extended.

There are questions on this aspect in the exam and so you should remember that StringBuffer and StringBuilder are also final.

All Primitive wrappers are also final (i.e. Boolean, Integer, Byte etc).

java.lang.System is also final.




PreviousNext

Related