OOPS Concept


  • Wrapping up of data under a single unit.
  • Variable or data hidden from other classes
  • Getter/Setter Concept
  • Advt: Data-Hiding, Increase Complexity,Reusability and Easy Testing


  • Polymorphism is the ability of an object to take on many forms.
  • Parent class reference is used to refer to a child class object.
  • Any Java object that can pass more than one IS-A test is polymorphic.
  • At run-time, it depends on the type of the object being referred to (not the type of the reference variable) that determines which version of an overridden method will be executed
  • A superclass reference variable can refer to a subclass object. This is also known as upcasting. Java uses this fact to resolve calls to overridden methods at run time.
  • A => B => C then
    • A a = new A => call method of A
    • A a = new B => call method of B
    • A a = new C => call method of C


  • One class inherits features of parent/base class
  • Types:
    • Single a => b
    • Multiple a => b => c
    • Hierarchical a=>b a=>c a=>d
    • Multiple a =>c b=>c (Only through Interface)
    • Hybrid combination of any two above (Only through Interface)


  • Class can redefine method of parent class
  • Signature should be same (return type,no of pram,param type)
  • Runtime Polymorphism
  • Final to avoid overriding
  • We cannot give weaker access modifier
  • Default > protected > public
  • Static method are not considered for overriding
  • Super keyword
  • Call overridden method without knowing object class

Overriding vs Overloading

  • Overloading is about have same method different signature | Overriding is about having same signature and same method but diff class
  • Overloading is compile time polymorphism and overriding is runtime

Invariant And Covariant

  • Invariant is normally a overriding concept
  • Covariant is when overridden can have different return type but should be sub type.


  • IS-A
  • Aggregation : has-A ( Relation: Institute => => )
    • Weaker association
  • Composition: part-of Relation: (Library => )
    • Strong association



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: