0% found this document useful (0 votes)
3 views2 pages

Java OOP Notes

The document provides beginner-friendly notes on Object Oriented Programming (OOP) concepts, including definitions and examples of classes, objects, encapsulation, inheritance, polymorphism, abstraction, and interfaces. It emphasizes the importance of OOP for code reusability, scalability, and maintainability. Each concept is illustrated with simple code snippets for better understanding.

Uploaded by

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

Java OOP Notes

The document provides beginner-friendly notes on Object Oriented Programming (OOP) concepts, including definitions and examples of classes, objects, encapsulation, inheritance, polymorphism, abstraction, and interfaces. It emphasizes the importance of OOP for code reusability, scalability, and maintainability. Each concept is illustrated with simple code snippets for better understanding.

Uploaded by

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

Java OOP Concepts - Beginner Friendly Notes

1. What is OOP?

OOP (Object Oriented Programming) is a programming concept where we use objects and classes
to design programs. It helps in code reusability, scalability, and maintainability.

2. Class and Object

Class is a blueprint, Object is an instance of class.

class Car {
String color;

void drive() {
[Link]("Car is driving");
}
}

public class Main {


public static void main(String[] args) {
Car c = new Car();
[Link] = "Red";
[Link]();
}
}

3. Encapsulation

Encapsulation means wrapping data and methods into a single unit and restricting direct access
using private variables.

class Student {
private int age;

public void setAge(int age) {


[Link] = age;
}

public int getAge() {


return age;
}
}

4. Inheritance

Inheritance allows one class to use properties of another class.

class Animal {
void sound() {
[Link]("Animal makes sound");
}
}

class Dog extends Animal {


void bark() {
[Link]("Dog barks");
}
}

5. Polymorphism

Polymorphism means same method behaves differently.

class Math {
int add(int a, int b) {
return a + b;
}

int add(int a, int b, int c) {


return a + b + c;
}
}

6. Abstraction

Abstraction means hiding implementation and showing only functionality.

abstract class Vehicle {


abstract void start();
}

class Bike extends Vehicle {


void start() {
[Link]("Bike starts with kick");
}
}

7. Interface

Interface is used for full abstraction.

interface Animal {
void sound();
}

class Cat implements Animal {


public void sound() {
[Link]("Meow");
}
}

You might also like