Class and Object

Object-Oriented Programming is a very vital topic in java as well as any other high-level programming language. The main purpose of object-oriented programming is to increase the flexibility and maintainability of programs.

The core concepts are:

  1. Class
  2. Object
  3. Method
  4. Constructor
  5. Inheritance
  6. Encapsulation
  7. Polymorphism
  8. Abstraction
  9. Interface

1. Class:
A Class is a blueprint that states the properties and behavior of an object.

class Car{
  String brand= "Toyota";
  String model= "Premio";

  public static void main(String[] args) {
    Car myCar= new Car();

2. Object:
An Object is an instance of a class. In the above example, myCar is an object. An object can be initiated by using new keyword before the class. An object can contain both properties and function.

about author


If you like my post or If you have any queries, do not hesitate to leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *