Basic OOP concepts in Java

//
//

sparetimecoding

I know this is too basic, but, sometimes we need to check this basic things out to remember what we are using and why. So here it is my 50 cents about basic Object Oriented Programming concepts. Basically:

INHERITANCE
ENCAPSULATION
POLYMORPHISM
ABSTRACTION

INHERITANCE

  • Superclass: abstracts out common features of other classes
  • Subclass:
    • inherits fields and methods from superclass, except the private ones
    • overrides(existing methods) or extends(create own methods) methods from superclass.
    • a subclass can override a method from the superclass provided that it is not final (if it is static cannot be overridden by redeclared)
    • define changes from superclass
    • Java supports only single inheritance
    • super: invoking a superclass version of an overridden method
    • protected is like private but subclasses can inherit from them
public class Animal {...
public class Dog extends Animal{...

 

ENCAPSULATION

  • Encapsulation is the technique of making the fields in a class private and providing…

View original post 401 more words

Advertisements

ضع تعليقك هنا

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

%d bloggers like this: