Select Category 
 

OOP Interview Questions Answers

OOP Interview Question - 1 : -

Differentiate Aggregation and containment?

OOP Interview Answer - 1 : -

Aggregation is the relationship between the whole and a part. We can add/subtract some properties in the part (slave) side. It won’t affect the whole part.
Best example is Car, which contains the wheels and some extra parts. Even though the parts are not there we can call it as car.
But, in the case of containment the whole part is affected when the part within that got affected. The human body is an apt example for this relationship. When the whole body dies the parts (heart etc) are died.
 

OOP Interview Question - 2 : -

What are inner class and anonymous class?

OOP Interview Answer - 2 : -

Inner class : classes defined in other classes, including those defined in methods are called inner classes. An inner class can have any accessibility including private. Anonymous class : Anonymous class is a class defined inside a method without a name and is instantiated and declared in the same place and cannot have explicit constructors.
 

OOP Interview Question - 3 : -

What is the difference between procedural and object-oriented programs?

OOP Interview Answer - 3 : -

1. In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOP program, unit of program is object, which is nothing but combination of data and code.
2. In procedural program, data is exposed to the whole program whereas in OOPs program, it is accessible with in the object and which in turn assures the security of the code.
 

OOP Interview Question - 4 : -

Differentiate persistent & non-persistent objects ?

OOP Interview Answer - 4 : -

Persistent refers to an object’s ability to transcend time or space. A persistent object stores/saves its state in a permanent storage system with out losing the information represented by the object.
A non-persistent object is said to be transient or ephemeral. By default objects are considered as non-persistent.
 

OOP Interview Question - 5 : -

When does a name clash occur?

OOP Interview Answer - 5 : -

A name clash occurs when a name is defined in more than one place. For example., two different class libraries could give two different classes the same name. If you try to use many class libraries at the same time, there is a fair chance that you will be unable to compile or link the program because of name clashes.
 

OOP Interview Question - 6 : -

Does a class inherit the constructors of its superclass?

OOP Interview Answer - 6 : -

A class does not inherit constructors from any of its super classes.

If a class is declared without any access modifiers, where may the class be accessed?
A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.

 

OOP Interview Question - 7 : -

What is Downcasting ?

OOP Interview Answer - 7 : -

Downcasting is the casting from a general to a more specific type, i.e. casting down the hierarchy.
 

OOP Interview Question - 8 : -

What is meant by “method-wars”?

OOP Interview Answer - 8 : -

Before 1994 there were different methodologies like Rumbaugh, Booch, Jacobson, Meyer etc who followed their own notations to model the systems. The developers were in a dilemma to choose the method which best accomplishes their needs. This particular span was called as “method-wars”
 

OOP Interview Question - 9 : -

Differentiate persistent & non-persistent objects?

OOP Interview Answer - 9 : -

Persistent refers to an object’s ability to transcend time or space. A persistent object stores/saves its state in a permanent storage system with out losing the information represented by the object.
A non-persistent object is said to be transient or ephemeral. By default objects are considered as non-persistent.

 

 

OOP Interview Question - 10 : -

Why generalization is very strong?

OOP Interview Answer - 10 : -

Even though Generalization satisfies Structural, Interface, Behaviour properties. It is mathematically very strong, as it is Antisymmetric and Transitive. Antisymmetric: employee is a person, but not all persons are employees. Mathematically all As’ are B, but all Bs’ not A.
 

OOP Interview Question - 11 : -

How many ways can an argument be passed to a subroutine?

OOP Interview Answer - 11 : -

An argument can be passed in two ways. They are Pass by Value and Passing by Reference.

Passing by value: This method copies the value of an argument into the formal parameter of the subroutine.

Passing by reference: In this method, a reference to an argument (not the value of the argument) is passed to the parameter.

 

OOP Interview Question - 12 : -

What do you meant by active and passive objects?

OOP Interview Answer - 12 : -

Active objects are one which instigate an interaction which owns a thread and they are responsible for handling control to other objects. In simple words it can be referred as client.
Passive objects are one, which passively waits for the message to be processed. It waits for another object that requires its services. In simple words it can be referred as server.
 

OOP Interview Question - 13 : -

Differentiate the class representation of Booch, Rumbaugh and UML?

OOP Interview Answer - 13 : -

If you look at the class representation of Rumbaugh and UML, It is some what similar and both are very easy to draw.
 

OOP Interview Question - 14 : -

Differentiate Aggregation  and containment?

OOP Interview Answer - 14 : -

Aggregation is the relationship between the whole and a part. We can add/subtract some properties in the part (slave) side. It won’t affect the whole part. Best example is Car, which contains the wheels and some extra parts. Even though the parts are not there we can call it as car. But, in the case of containment the whole part is affected when the part within that got affected. The human body is an apt example for this relationship. When the whole body dies the parts (heart etc) are died.
 

OOP Interview Question - 15 : -

Whether unified method and unified modeling language are same or different?

OOP Interview Answer - 15 : -

Unified method is convergence of the Rumbaugh and Booch. Unified modeling lang. is the fusion of Rumbaugh, Booch and Jacobson as well as Betrand Meyer (whose contribution is “sequence diagram”). Its’ the superset of all the methodologies.