0% found this document useful (0 votes)
10 views

WBP All Questions Answers

Chapter 03 discusses key object-oriented concepts in PHP, including concrete classes, abstract classes, introspection, and serialization. It explains parameterized constructors, compares method overloading and overriding, and contrasts interfaces with abstract classes. The chapter provides definitions, examples, and comparison tables to illustrate these concepts.

Uploaded by

thoratatul131
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

WBP All Questions Answers

Chapter 03 discusses key object-oriented concepts in PHP, including concrete classes, abstract classes, introspection, and serialization. It explains parameterized constructors, compares method overloading and overriding, and contrasts interfaces with abstract classes. The chapter provides definitions, examples, and comparison tables to illustrate these concepts.

Uploaded by

thoratatul131
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Chapter No: 03 - Apply Object Oriented Concept in PHP (CO3)

2 Marks Questions

1. Describe term concrete class.

A concrete class is a class that has complete implementation and can be instantiated to create objects. Unlike abstract

classes, it does not contain any abstract methods.

2. Describe abstract class and abstract method.

An abstract class is a class that cannot be instantiated. It may contain abstract methods which do not have any

implementation and must be defined in child classes.

Example:

abstract class Shape {

abstract protected function area();

3. Describe term Introspection.

Introspection in PHP refers to the ability to examine classes, interfaces, properties, and methods at runtime using

reflection APIs like get_class(), get_methods(), etc.

4. Describe term Serialization.

Serialization is the process of converting a PHP object or value into a storable string format that can be saved or

transferred.

$serializedData = serialize($object);

4 Marks Questions
1. Describe parameterized constructor with suitable example.

A constructor that takes parameters to initialize object properties.

class Student {

public $name;

function __construct($name) {

$this->name = $name;

$stud = new Student("John");

2. Compare method overloading and method overriding.

| Feature | Overloading | Overriding |

|---------------|--------------------------------|-----------------------------------------|

| Definition | Same method, different params | Redefines parent method in child class |

| Purpose | Multiple functionalities | Modify base class behavior |

| PHP Support | Not direct | Fully supported |

3. Compare interface and abstract class.

| Feature | Abstract Class | Interface |

|------------------|----------------------------|-------------------------------|

| Methods | Abstract and defined | Only abstract (pre PHP 8) |

| Inheritance | Single | Multiple |

| Access Modifiers | Any | Public only |

(Additional chapters will continue on next pages)

You might also like