What is Abstraction: Abstraction is an important concept in OOPS in which the implementation details are hidden. It focus on what the object does instead of how. Abstraction is accomplished using abstract classes and methods. Abstract Classes: 1. Declared as 'abstract' with the 'abstract' keyword 2. Whose instance(object) can't be created. 3. Does not support Multiple inheritance i.e. extending more than one class. 4. Contains constructors, at-least one abstract method(compulsory),non-abstract methods(optional) and data members(properties) 5. Can have protected and public abstract methods. Abstract Methods: 1. A method without body i.e, no definition only declaration. 2. Must be declared in abstract class 3. If a regular class extends an abstract class, then the class needs to implement all the abstract methods of the Parent Abstract class or it has to be declared abstract as well. Advantages: 1. Reduces complexity 2. Avoids Code duplication and increases re-usablilty 3. Help in developing more secure applications 4. Keeps the program organised and understandable Syntax of Abstract classes and methods: abstract class className{ abstract public function functionName(); public functionName2(){ // some operations } }Please check the attached screenshot for example. You can check by using: /* $child1 = new B('John Doe'); echo $child1->printName().' ' ; $child2 = new C('Jane Doe'); echo $child2->abs1().' ' ; */ Feel free to contact me if you have any questions or you can comment it down. - Study24x7
Social learning Network
58 followers study24x7 06 May 2020 05:36 PM study24x7 study24x7

What is Abstraction: Abstraction is an important concept in OOPS in which the implementation details are hidden. It focus on what the object does instead of how. Abstraction is accomplished using abstract classes and methods. Abstract Classes: 1. Declared as 'abstract' with the...

See more

What is Abstraction:

Abstraction is an important con...
study24x7
Write a comment
  • Nidhi Gupta
  • Note*- Abstraction is achieved by abstract classes and interfaces
    Related Questions
    500+   more Questions to answer
    Most Related Articles