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:: cannot inherit from final java.lang.String
C: public class MyStrintg extends String
C:
C: 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
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
