Class Model


Object : objects are conceptually similar to real-world objects: they too consist of state and related behavior

Class : class is the blueprint from which individual objects are created.

Inheritance : Different kinds of objects often have a certain amount in common with each other. Mountain bikes, road bikes, and tandem bikes

class MountainBike extends Bicycle {

    // new fields and methods defining 
    // a mountain bike would go here

}

A diagram of classes in a hierarchy.





Interface : Methods form the object's interface with the outside world; the buttons on the front of your television set, for example, are the interface between you and the electrical wiring on the other side of its plastic casing. You press the "power" button to turn the television on and off.

Encapsulation : Hiding internal state and requiring all interaction to be performed through an object's methods is known as data encapsulation.
The variables of a class can be accessed only through the public methods

We can control and check the input values

public class Animal {
   private String name;
   private double height;
   private double weight;
   private String sound;

public void setWeight(int newWeight){
   if (newWeight > 0 && newWeight <10000 ){
      weight = newWeight;
   } 
   else {
      System.out.println("Weight must be bigger than 0 and smaller than 10000");
   }
}

Polymorphism : 


Abstraction : multi interface.