Question: Question A programmer tries to create a subclass of String called MyString. When the programmer compiles her new class, the compiler produces the following message:

Question
A programmer tries to create a subclass of String called MyString. When the programmer compiles her new class, the compiler produces the following message:
C: > MyString.java:1: cannot inherit from final java.lang.String
C: > public class MyStrintg extends String {
C: >
C:>1 error
Explain the cause of this error.
Answer: The String class has been declared with the final modifier, which restricts any other classes from extending it.
 Question A programmer tries to create a subclass of String called

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!