Explain use of final and super keywords in Java.
### The `final` Keyword:
In Java, the `final` keyword is used to restrict the functionality of a class, method, or variable. Once a class is declared as `final`, it cannot be subclassed, meaning no other class can extend it. When applied to a method, the `final` keyword indicates that the method cannot be overridden by subclasses. Finally, when used with a variable, it means the variable is a constant and cannot be reassigned after its initial assignment.
#### 1. Final Classes:
```java
final class Example {
// Class implementation
}
```
In this example, the class "Example" is declared as final, and no other class can extend it.
#### 2. Final Methods:
```java
class Parent {
final void display() {
___ ____ _____ _____ ____ ________.
_______ _______ _______ ________ _______.
_______ _________ _________ _________ ________ _______ _________ ____ _________ __________ _______ _________.
________ ____ _____ ________ ____ _______ _________ ____ _______.
__________ ____ _________ ______ _____.
_______ ______ ________ _________ _____ _____ ____ ____ ____ _____ _____ ___.
________ _________ ________ __________ _____ _______.
_____ ________ ________ __________ __________ _____.
________ __________ ________ ___ _______.
_________ _________ _______ ___ ________ __________ __________.
__________ ________ __________ ________ _____ ___ ________ _________ ___ _________.
_________ ___ _____ _________ _______ __________ _____ ________ _________ ________ _____.
_________ ___ ______ ________ ________ _________ _________ ________ ____.
____ _____ _____ ______ ________ ____ ________ _____ ___ ___ ______.
___ ____ __________ _____ _____ _____ _______ ________ _________.
_______ ________ ______ ________ _______ _____.
_______ ____ ___ _______ __________ _____ ______ __________ ______ ____.
___ ____ _____ ___ ________ __________ _____ _________ _____ _______ ______ ___.
______ _____ ____ ________ ____ ______ _____ ______ _____.
______ ___ __________ ___ ______ ____ ____ __________ ____ _______ _________ _______.
__________ _________ __________ ____ ______ _______.
____ ______ ______ _____ _________ ________ __________ __________.
___ __________ _______ _______ ___ ______ ______ __________ ____.
____ _____ _______ _______ _________ ____ ________ ____ __________ _____.
_________ __________ _______ __________ _________ ___ ________ ________ _______ _________.
_____ ________ __________ __________ _______ _________ ________ ______ ____ _________ _________.
_________ ________ ____ _____ _____ ___ ______ ____ _______.
______ _______ ________ _________ ______ _____ ______ __________.
_____ ________ _________ ________ __________ ____ _________ ___ ________ ___.
___ ____ ________ ____ ______ _____ _____ ___.
__________ ________ _____ ______ _________.
______ __________ __________ ___ __________ ___ ________ ______ _______ ________ ___.
__________ ______ _______ __________ ______ _____ ____ _____ ____ ______.
________ ______ _______ ________ _________ _________ ___.
______ _______ _______ _________ _____ _____ ____.
__________ _________ ___ __________ _______.
____ ________ ____ __________ _______ ___ __________ ______ __________ _____ ___.
_______ ____ _____ _________ ____ ____ ____ ____ ___ ______.
______ ___ ____ ___ __________ ________ _________ _____ _________ _____ ______ _____.
______ ______ __________ _____ _______ _____ ____ __________ _________ __________ ___ ___.
_________ ________ ________ ______ _________.
_________ _____ _____ ___ _______.
________ _____ _____ _______ _____ _______ ___.
______ ___ ____ __________ ____ ___ _______ ___ _________ ________ ____ _________.
____ _____ ___ _____ ________ ________ ______ __________ ______ _________.
________ ___ _________ _____ ___ _____ _____ _________ ____.
________ ______ ____ _____ ______.
_______ __________.
Get Full Answer on WhatsApp