1) class
- class is tha logical entity
- is tha blue print
-
is tha template
ex
class Car {
String brand;
int year;void displayInfo() {
System.out.println("Brand: " + brand);
System.out.println("Year: " + year);
}
}
2) object
- object is tha phycial entity *is tha repercent of tha class *is tha instant of tha class
- each object as is own state and behaviours ex;
public class Main {
public static void main(String[] args) {
// Object
Car myCar = new Car();
myCar.brand = "Toyota";
myCar.year = 2020;
myCar.displayInfo();
}
}
Top comments (0)