0% found this document useful (0 votes)
1 views

OOP_in_Java

The document explains the basics of Object-Oriented Programming (OOP) in Java, highlighting its key principles: encapsulation, inheritance, polymorphism, and abstraction. It emphasizes the importance of these principles for creating modular, scalable, and maintainable code. An example of class inheritance is provided to illustrate the concepts discussed.

Uploaded by

Bobby Joe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

OOP_in_Java

The document explains the basics of Object-Oriented Programming (OOP) in Java, highlighting its key principles: encapsulation, inheritance, polymorphism, and abstraction. It emphasizes the importance of these principles for creating modular, scalable, and maintainable code. An example of class inheritance is provided to illustrate the concepts discussed.

Uploaded by

Bobby Joe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Title: Basics of Object-Oriented Programming in Java

Introduction:
Object-Oriented Programming (OOP) is a paradigm that uses “objects” to design
applications and programs. Java is one of the most popular OOP languages.

Key Principles of OOP:

1. Encapsulation:
- Hiding internal state and requiring all interaction through methods.
- Achieved using private fields and public getter/setter methods.

2. Inheritance:
- Allows a new class to inherit properties and methods from an existing class.
- Promotes code reuse.
- Syntax: `class Subclass extends Superclass`

3. Polymorphism:
- Ability of different objects to respond differently to the same method call.
- Compile-time (method overloading) and runtime (method overriding) polymorphism.

4. Abstraction:
- Hiding complex implementation details and showing only necessary features.
- Achieved using abstract classes and interfaces.

Example:
```java
class Animal {
void makeSound() {
System.out.println("Animal sound");
}
}

class Dog extends Animal {


void makeSound() {
System.out.println("Bark");
}
}
```

Conclusion:
OOP in Java enables modular, scalable, and maintainable code. Mastering the four
principles is key to effective Java programming.

You might also like