Category : Java | Sub Category : Object- oriented Programming | By Runner Dev Last updated: 2020-11-28 18:43:34 Viewed : 174


  • Java is an object-oriented language
  • Its constructs represent concepts from the real world.
  • Each Java program has at least one class that knows how to do certain actions or has properties
  • Classes in Java may have methods and properties (a.k.a. attributes or fields)

                                                Example 1: Car Class

    Example 2: Creating Car Objects

    Now the variables car1 and car2 represent new instances of Car:

    car1.color=“blue”; car2.color=“red”;!

    These two Car instances are created with the new operator:

     Car car1 = new Car();

    Car car2 = new Car();

    Related Articles

    Leave a Comment: