Posts

What is a Class in Java

Image
  What is a Class? In the real world, we often find many individual objects all of the same kind. In terms of cars,   there may be hundreds of other cards in your town alone . They may be of the same make and model. But each car was built from the same set of blueprints. Therefore they contains the same components.  Let's apply this analogy to bicycles in your town. In object-oriented concept, we say that any physical  bicycle is an instance of the  of bicycle class. All individual bicycle objects  are created from that blueprint bicycle class. Here is a one bicycle class  class Bicycle {     int speed = 0;     int gear = 1     void changeGear(int newValue) {          gear = newValue;     }     void speedUp(int increment) {          speed = speed + increment;        }     void applyBrakes(int decrement) {   ...

What is an Object in Java

Image
  What is an object really ? They are real world things around us. They share two characteristics: They all have state and behavior. Dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging Bicycles also have state (current gear, current pedal cadence, current speed) and behavior (changing gear, changing pedal cadence, applying brakes).  Identifying the state and behavior for real-world objects is a great way to begin thinking in terms of object-oriented programming. Study any two  real world objects and note down their states and behaviors. What similarities and differences do they have ,? Create diagrams like this on your notes book.  Compare and contrast . Learn more  https://docs.oracle.com/javase/tutorial/java/concepts/object.html https://www.guru99.com/java-oops-class-objects.html