In this Java program, you've defined a final class called FinalClass, and then you've attempted to create a class named DerivedClass that extends FinalClass. However, this will result in a compilation error because you cannot inherit from a final class.
The final keyword, when applied to a class, indicates that the class cannot be subclassed or extended. Therefore, any attempt to create a subclass (like DerivedClass) from a final class (FinalClass) will lead to a compilation error.
final class FinalClass { // Some final class members } // This line will result in a compilation error since FinalClass is final class DerivedClass extends FinalClass { // Some code here }
Error : cannot inherit from final FinalClass
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions