I am Learning Object Oriented Programming (Java) :)



What is an Object ?



  If we think the real world, actually everything is an object around us... These objects have some states, behaviours and surely identity. For object oriented programming, same thing is valid about objects.

                                      

  Every object in OOP has states(what we know about object/ properties/ fields/ variables etc. ), also they have behaviours(what an object can do/ resposibilities/ methods(functions) ), and identity(place in memory/ physical location/ memory address).



Classes



  We need a class in order to store objects. Wtihout any class we can not create an object for our project.  Classes are blueprint/prototype for creating object.
  We define states and behaviours in our classes.


Inheritance vs. Composition

  Inheritance and Composition let us to create new type from existing types. 
In Inheritance, superclasses (drived class interface) have subclasses(base class interface). Superclass can be upcast to subclass. This is very important for polymorphism (next subject). Composition tends to be more flexible than Inheritance.




Hiç yorum yok:

Yorum Gönder