Java Final Class
Chapter:
Inheritance
Last Updated:
02-08-2017 16:22:22 UTC
Program:
/* ............... START ............... */
public class JavaFinalClass {
}
final class Bike {
}
class Honda1 extends Bike {
void run() {
System.out.println("running safely with 100kmph");
}
public static void main(String args[]) {
Honda1 honda = new Honda();
honda.run();
}
}
/* ............... END ............... */
Output
Output:Compile Time Error
Notes:
-
Java class with the final modifier is called the final class in Java. The final class is complete in nature and can not be sub-classed or inherited. Several classes in Java are final e.g. String, Integer, and other wrapper classes.
Tags
Final Class, Java, Inheritance