Features
Features
Java is a fully object-oriented programming language that follows OOP principles such
as Encapsulation, Inheritance, Polymorphism, and Abstraction.
1. Encapsulation – Wrapping data and methods into a single unit using private
variables and public getters/setters.
1. Encapsulation
class Car {
// Setter Method
this.model = model;
// Getter Method
return model;
2. Inheritance
// Parent Class
class Animal {
void makeSound() {
void bark() {
System.out.println("Dog barks");
3. Polymorphism
class MathOperations {
return a + b;
}
int add(int a, int b, int c) {
return a + b + c;
class Animal {
void makeSound() {
@Override
void makeSound() {
System.out.println("Dog barks");
4. Abstraction
void stop() {
System.out.println("Vehicle is stopping...");
@Override
void start() {
System.out.println("Car is starting...");
Using Interface
interface Animal {
@Override
public void makeSound() {
System.out.println("Dog barks");
myDog.makeSound();