OOPS interview questions and Answers

Last update: 23 Apr 2021, 18 Questions

OOPS Stands for Object-Oriented Programming System. It refers to the languages which are using objects in programming. The objective of OOPS is to carry out practical entities such as hiding, abstraction, polymorphism, and more into coding.

If you are new to OOPS or want to improve your skills. Here is a list of the most frequently asked OOPS Interview Questions which can help you crack that dream job as an OOPS Developer. You can also download the OOPS Interview Questions and Answers in the form of a PDF format to access it anytime, on any device, offline.

While implementing these entities, OOPS aims to increase the efficiency of code by binding the data and its functions needed for operation in such a way that accessibility to data remains limited to the functions which need them, thus, keeping your code extremely organized.

Most Frequently Asked OOPS interview questions

Here in this article, we will be listing frequently asked OOPS interview questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.

1. What is OOPS?

OOPS stands for Object Oriented Programming system. It is a programming technique which is used to design your application. In this programs are considered as a collection of objects and each object is an instance of a class.

54 10
2. Write basic concepts of OOPS?
  • Inheritance
  • Polymorphism
  • Encapsulation
  • Abstraction etc
36 3
3. What is class?

Class is a user-defined datatype that contains variables, properties, and methods. It defines properties of an Object



class Person{

    public $name;

    function __construct($name){

        $this->name = $name;


    function getUserDetails(){

        return "My name is ".$this->name;



18 1
4. What is Encapsulation?

It is an attribute of an object, and it contains all data which is hidden. That hidden data is restricted to the members of that class.

24 15
5. What is Polymorphism?

It takes more than one form. It is nothing but assigning behavior or value in a subclass to something that was already declared in the main class.

8 4
6. What is Inheritance?

It is a technique in which one class acquires the property of another class. With the help of inheritance, we can reuse the fields and methods of the existing class.

Inheritance has three type, are given below.

  • Single inheritance
  • Multiple inheritance
  • Multi level inheritance

But PHP supports only single inheritance, where only one class can be derived from single parent class. We can also use multiple inheritance by using interfaces.

14 2
7. What is constructor and destructor?

Constructor and Destructor both are special functions which are automatically called when an object is created and destroyed.




class Animal


     public $name = "No-name animal";

     public function __construct() {

     echo "I'm alive!";




class Animal {

public $name = "No-name animal";

public function __construct($name) {

echo "I'm alive!";

$this->name = $name;


public function __destruct() {

echo "I'm dead now :(";



$animal = new Animal("Bob");

echo "Name of the animal: " . $animal->name;


5 6
8. What is different types of Visibility?

PHP have three access modifiers such as public, private and protected.

  • public scope of this variable or function is available from anywhere, other classes and instances of the object.
  • private scope of this variable or function is available in its own class only.
  • protected scope of this variable or function is available in all classes that extend current class including the parent class.
13 1
9. What is final class and final method?

It's properties can not be declared final, only classes and methods may be declared as final. If the class or method defined as final then it cannot be extended.



class childClassname extends parentClassname {
    protected $numPages;

    public function __construct($author, $pages) {
        $this->_author = $author;
        $this->numPages = $pages;

    final public function PageCount() {
        return $this->numPages;

6 6
10. What is static keyword ? When a variable or function declared as static then it cannot be accessed with an instantiated class object. It is treats as public if no visibility is defined. It can also be used to define static variables and for late static bindings.
5 1
11. What are the difference between overloading and overriding in oops?

Overloading : It occurs when two or more methods in one class have the same method name but different parameters.

Overriding : It means having two methods with the same method name and parameters. One of the methods is in the parent class and the other is in the child class.

9 0
12. What is "this"?

It refers to the current object of a class.

6 0
13. What are the difference between abstract class and interface in OOPS?

Thera are many differences between abstract class and interface in php.

1. Abstract methods can declare with public, private and protected. But in case of Interface methods declared with public.

2. Abstract classes can have constants, members, method stubs and defined methods, but interfaces can only have constants and methods stubs.

3. Abstract classes doest not support multiple inheritance but interface support this.

4. Abstract classes can contain constructors but interface doest not support constructors.

5 3
14. What is namespace in PHP?

It allows us to use the same function or class name in different parts of the same program without causing a name collision.

namespace MyAPP;
function output() {
echo 'IOS!';
namespace MyNeWAPP;
function output(){
echo 'RSS!';


6 2
15. What is traits? How it is used in php?

Traits is a group of methods that reuse in single inheritance. A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods.



trait HelloWorld


use Hello, World;


class MyWorld {

use HelloWorld;


$world = new MyWorld();

echo $world->sayHello() . " " . $world->sayWorld(); //Hello World

4 1
16. What are the advantages of OOPS in PHP?
  • Code Resusability
  • Flexibility
  • Maintainability
  • Security
  • Testability
4 1
17. What is member variable?

Member variables defined inside a class. Data of member variables will be invisible to the outside of the class and can be accessed via member functions. These variables are called attribute of the object once an object is created.

5 1
18. What is member function?

Member function defined inside a class and are used to access object data.

6 1
About Umesh Singh
Umesh Singh
Full Stack Developer

My name is Umesh Singh having 7+ experience in Node.JS, React JS, PHP, Laravel, WordPress, MySQL, JavaScript, HTML and CSS etc. I have worked on around 20+ projects. I love programming, coding and most of my time goes in learning the best ways to write clean code. When I am not found coding, I can be seen helping out tech geeks. I am always open to help you.