Category: React • Beginner
Published on 18 Feb 2026
Explanation
final is a keyword in Java used to restrict modification. It can be applied to variables, methods, and classes.
Code Example
final int x = 10;
Explanation
A final variable cannot be reassigned once it is initialized.
Code Example
final int number = 100; // number = 200; // Compilation Error
Explanation
A final method cannot be overridden by a subclass.
Code Example
class Parent {
final void display() {
System.out.println("Final Method");
}
}
class Child extends Parent {
// void display() {} // Error
}
Explanation
A final class cannot be extended by another class.
Code Example
final class Animal {
}
// class Dog extends Animal {} // Error