Advanced OOP Interview Questions and Answers for Experienced


Q1: What is inheritance?
Answer:
Inheritance allows us to define a class in terms of another class, which makes it easier to create and maintain an application. This also provides an opportunity to reuse the code functionality and speeds up implementation time.
When creating a class, instead of writing completely new data members and member functions, the programmer can designate that the new class should inherit the members of an existing class. This existing class is called the base class, and the new class is referred to as the derived class.
The idea of inheritance implements the IS-A relationship. For example, mammal IS-A animal, dog IS-A mammal hence dog IS-A animal as well, and so on.
Q2: What is object-oriented programming (OOP)?
Answer:
OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object is created in the program to represent a class. Therefore, an object encapsulates all the features, such as data and behavior that are associated with a class. OOP allows developers to develop modular programs and assemble them as software. Objects are used to access data and behaviors of different software modules, such as classes, namespaces, and sharable assemblies. .NET Framework supports only OOP languages, such as Visual Basic .NET, Visual C#, and Visual C++.
Q3: What is encapsulation?
Answer:
Encapsulation is defined as the process of enclosing one or more items within a physical or logical package. Encapsulation, in object-oriented programming methodology, prevents access to implementation details.
Q4: What is polymorphism?
Answer:
The word polymorphism means having many forms. In the object-oriented programming paradigm, polymorphism is often expressed as one interface, multiple functions.
Q5: What is the difference between procedural and object-oriented programming?
Answer:
Procedural programming is based upon the modular approach in which the larger programs are broken into procedures. Each procedure is a set of instructions that are executed one after another. On the other hand, OOP is based upon objects. An object consists of various elements, such as methods and variables.
Access modifiers are not used in procedural programming, which implies that the entire data can be accessed freely anywhere in the program. In OOP, you can specify the scope of particular data by using access modifiers – public, private, internal, protected, and protected internal.

Leave a Reply