Thursday, 26 December 2013

Object and pillars of OOPs

Object

Object is a real world entity who has well define structure and behaviour. For example: chair, table, pen etc. It can be tangible or intangible (physical or logical).

Characteristics of object:

  • State: represents the data of an object

  • Behaviour: represents the behaviour of an object.

  • Identity: Object identity is typically implemented via a unique ID. The value of the ID is not visible to the external user, but is used internally by the JVM to identify each object uniquely

  • Responsibility


Major pillars of OOPs : 

  • Abstraction

  • Encapsulation

  • Inheritance

  • Polymorphysim

Abstraction is a process of exposing essential features of an entity by hiding the other irrelevant details.
 
Encapsulation is the process of putting data and the operations (functions) that can be performed on that data into a single container called class.
 
Inheritance is a process of creating new class from the existing one. Child class inheriting properties from base class.

Polymorphism refers to the ability to take multiple forms. Different  ways or reactions for same instruction is polymorphism.

Why array index starts from zero 
 
The index of array, which is of the form a[i], is converted
by the compiler in the form [a+i]. So, the index of first
element is zero because [a+0] will give 'a' & the first
array element can be accessed. Due to this, we can also
access the array elements as' i[a]' instead of 'a[i]' , &
this will not produce an error. 
 

No comments:

Post a Comment