Showing posts with label oops. Show all posts
Showing posts with label oops. Show all posts

Saturday, December 13, 2014

My OOPS Concepts

Don't repeat the code its a main concept of OOPS language

four pillar of OOPS
  1. Abstraction
  2. Polymorphism
  3. Encapsulation
  4. Inheritance
Scope Specifiers are
Public -> Can be access from anywhere
Private -> Declared on Class level, can't be inherit
Protected -> Accessible only for the direct child

Constructor in PHP:-
  1. PHP use another constructor __Constuctor()
  2. There should be only 1 constructor in PHP
  3. Constructor is created by its own
  4. constructor is the first function of the object
Abstraction:-
  1. Make some ideal code and use that further
  2. To define rules and regulations
  3. Data hiding
  4. Essential data is hidden
  5. If we extend the parent class then we must redefine all the abstract methods of abstract parent class
e.g.
If we switch On button then Television is getting on its our primary focus, don't need to worry what is happen its behind.

Polymorphism:-
  1. One thing has many form
  2. Function Overloading is the example of this
e.g.
db.php is the example of this one function accepts the diff parameters

Encapsulation:-
  1. To give permission to meet code
  2. Assign permission to meet code
  3. Assign Permission to meet data
  4. Public, Private, Protected
Interface:-
  1. Interface are extra methods and properties which we need to assign to class
  2. Multiple is possible with the help of Interface.
  3. All the useful methods and variables are assigned inside the Interface
e.g.
Class Shaktiman extends human
implements flying
implements runable
implements growable

Class Arjun extends human
implements bhramashtra