Java OOPs Notes Day6
Java OOPs Notes Day6
Example:
class Car {
String color;
void drive() {
System.out.println("Car is driving");
myCar.color = "Red";
myCar.drive();
Step 2: Constructor
- No return type
Example:
class Student {
String name;
Student(String n) {
name = n;
Example:
class Person {
String name;
Person(String name) {
this.name = name;
Step 4: Encapsulation
Wrapping data and code together using private fields and public methods.
Example:
class Account {
Step 5: Inheritance
Example:
class Animal {
}
Java OOPs - Step-by-Step Notes
Step 6: Polymorphism
Overloading:
Overriding:
Step 7: Abstraction
Example:
Summary Table
Class: Blueprint
Inheritance: Reusability
Java OOPs - Step-by-Step Notes