Interview questions for OOPS

1. What is Object Oriented Programming?

Object-Oriented Programming(OOPs) is a type of programming that is based on objects rather than just functions and procedures. Individual objects are grouped into classes. OOPs implements real-world entities like inheritance, polymorphism, hiding, etc into programming. It also allows binding data and code together.

2. What is static and dynamic Binding?

Binding is nothing but the association of a name with the class. Static Binding is a binding in which name can be associated with the class during compilation time, and it is also called as early Binding.
Dynamic Binding is a binding in which name can be associated with the class during execution time, and it is also called as Late Binding.

3. How many instances can be created for an abstract class?

Zero instances will be created for an abstract class. In other words, you cannot create an instance of an Abstract Class.

4. Which keyword can be used for overloading?

Operator keyword is used for overloading.

5. What is the default access specifier in a class definition?

Private access specifier is used in a class definition.

6. Which OOPS concept is used as a reuse mechanism?

Inheritance is the OOPS concept that can be used as a reuse mechanism.

7. What is operator overloading?

Operator overloading is a function where different operators are applied and depends on the arguments. Operator,-,* can be used to pass through the function, and it has its own precedence to execute

8. What is an abstract class?

An abstract class is a class which cannot be instantiated. Creation of an object is not possible with an abstract class, but it can be inherited. An abstract class can contain only an Abstract method. Java allows only abstract method in abstract class while other languages allow nonabstract method as well.

9. What is a ternary operator?

The ternary operator is said to be an operator which takes three arguments. Arguments and results are of different data types, and it depends on the function. The ternary operator is also called a conditional operator.

10. What is the use of finalize method?

Finalize method helps to perform cleanup operations on the resources which are not currently used. Finalize method is protected, and it is accessible only through this class or by a derived class.

11. What are the different types of arguments?

A parameter is a variable used during the declaration of the function or subroutine, and arguments are passed to the function body, and it should match with the parameter defined.

12. Why use OOPs?

• OOPs allows clarity in programming thereby allowing simplicity in solving complex problems
• Code can be reused through inheritance thereby reducing redundancy
• Data and code are bound together by encapsulation
• OOPs allows data hiding, therefore, private data is kept confidential
• Problems can be divided into different parts making it simple to solve
• The concept of polymorphism gives flexibility to the program by allowing the entities to have multiple forms

13. What are a base class, subclass and superclass?

The base class is the most generalized class, and it is said to be a root class. A Subclass is a class that inherits from one or more base classes. The superclass is the parent class from which another class inherits.

14. What is static and dynamic Binding?

Binding is nothing but the association of a name with the class. Static Binding is a binding in which name can be associated with the class during compilation time, and it is also called as early Binding. Dynamic Binding is a binding in which name can be associated with the class during execution time, and it is also called as Late Binding.

15. What are the main features of OOPs?

• Inheritance
• Encapsulation
• Polymorphism
• Data Abstraction
To know more about OOPs in JAVA, Python, and C++ you can go through the following blogs:
• JAVA OOPs Concepts
• Python OOPs Concepts
• C++ OOPs Concepts

16. What is Inheritance?

Inheritance is a concept where one class shares the structure and behavior defined in another class. If Inheritance applied to one class is called Single Inheritance, and if it depends on multiple classes, then it is called multiple Inheritance.

17. What are manipulators?

Manipulators are the functions which can be used in conjunction with the insertion (<<) and extraction (>>) operators on an object. Examples are endl and setw.

18. Explain the term constructor?

A constructor is a method used to initialize the state of an object, and it gets invoked at the time of object creation. Rules for constructor are:
• Constructor Name should be the same as a class name.
• A constructor must have no return type.

19. Define Destructor?

A destructor is a method which is automatically called when the object is made of scope or destroyed. Destructor name is also same as class name but with the tilde symbol before the name.

20. What is an Inline function?

An inline function is a technique used by the compilers and instructs to insert complete body of the function wherever that function is used in the program source code.

21. What is the difference between structure and a class?

The default access type of a Structure is public, but class access type is private. A structure is used for grouping data, whereas a class can be used for grouping data and methods. Structures are exclusively used for data, and it doesn’t require strict validation, but classes are used to encapsulate and inherent data, which requires strict validation.

22. What is the default access modifier in a class?

The default access modifier of a class is Internal and the default access modifier of a class member is Private.

23. What is an object?

An object is a real-world entity which is the basic unit of OOPs for example chair, cat, dog, etc. Different objects have different states or attributes, and behaviors.

24. What is a class?

A class is a prototype that consists of objects in different states and with different behaviors. It has a number of methods that are common the objects present within that class.

25. What is the difference between a class and a structure?

Class: User-defined blueprint from which objects are created. It consists of methods or set of instructions that are to be performed on the objects.
Structure: A structure is basically a user-defined collection of variables which are of different data types.

26. Can you call the base class method without creating an instance?

Yes, you can call the base class without instantiating it if:
• It is a static method
• The base class is inherited by some other subclass

leave your comment


Your email address will not be published. Required fields are marked *