Keywords Java
Keywords Java
1. sta c Keyword
Sta c variables or methods belong to the class and not to any specific instance (object) of
the class.
Example:
java
Copy code
class Car {
Output:
Copy code
2. final Keyword
Example:
java
Copy code
class Bike {
bike.showSpeedLimit();
Output:
bash
Copy code
Speed limit is 90
3. super Keyword
Example:
java
Copy code
class Animal {
void sound() {
}
class Dog extends Animal {
void sound() {
System.out.println("Dog barks");
dog.sound();
Output:
css
Copy code
Dog barks
4. this Keyword
Used to resolve conflicts between class a ributes and parameters with the same name or to
call other constructors.
Example:
java
Copy code
class Student {
int id;
String name;
void display() {
student.display();
Output:
yaml
Copy code
These keywords help manage object-oriented concepts like inheritance, constant values, and class-
level behavior.