Computer Knowledge

Object-Oriented Programming

2,239 Questions

Object-oriented programming questions test core computer science concepts like classes, inheritance, polymorphism, and encapsulation. The focus includes Java program structures, method overloading, and memory allocation for objects. This topic is essential for technical sections in various recruitment tests.

Java class definitionsMethod overriding rulesPolymorphism conceptsGeneric type parametersMemory allocation in objects

Object-Oriented Programming Questions

Multiple choice

What is the ability of an object to respond to different messages in different ways?

  1. Encapsulation

  2. Inheritance

  3. Polymorphism

  4. Abstraction

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Polymorphism is the ability of an object to respond to different messages in different ways.

Multiple choice

What is the process of creating a class that is a specialized version of another class?

  1. Encapsulation

  2. Inheritance

  3. Polymorphism

  4. Abstraction

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Inheritance is the process of creating a class that is a specialized version of another class.

Multiple choice

What is the process of hiding the implementation details of an object from the user?

  1. Encapsulation

  2. Inheritance

  3. Polymorphism

  4. Abstraction

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Abstraction is the process of hiding the implementation details of an object from the user.

Multiple choice

What is the process of creating a class from an existing class?

  1. Encapsulation

  2. Inheritance

  3. Polymorphism

  4. Abstraction

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Inheritance is the process of creating a class from an existing class.

Multiple choice

What is the ability of an object to respond to different messages in different ways?

  1. Encapsulation

  2. Inheritance

  3. Polymorphism

  4. Abstraction

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Polymorphism is the ability of an object to respond to different messages in different ways.

Multiple choice

What is the process of creating a class that is a specialized version of another class?

  1. Encapsulation

  2. Inheritance

  3. Polymorphism

  4. Abstraction

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Inheritance is the process of creating a class that is a specialized version of another class.

Multiple choice

What is the process of hiding the implementation details of an object from the user?

  1. Encapsulation

  2. Inheritance

  3. Polymorphism

  4. Abstraction

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Abstraction is the process of hiding the implementation details of an object from the user.

Multiple choice

What is the process of creating a class from an existing class?

  1. Encapsulation

  2. Inheritance

  3. Polymorphism

  4. Abstraction

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Inheritance is the process of creating a class from an existing class.

Multiple choice

What is the ability of an object to respond to different messages in different ways?

  1. Encapsulation

  2. Inheritance

  3. Polymorphism

  4. Abstraction

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Polymorphism is the ability of an object to respond to different messages in different ways.

Multiple choice

What is the process of creating a class that is a specialized version of another class?

  1. Encapsulation

  2. Inheritance

  3. Polymorphism

  4. Abstraction

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Inheritance is the process of creating a class that is a specialized version of another class.

Multiple choice

Which software design pattern is used to provide a uniform interface to a set of related objects?

  1. Factory Method

  2. Singleton

  3. Facade

  4. Builder

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The Facade design pattern is used to provide a uniform interface to a set of related objects.

Multiple choice

Which design pattern is used to define a family of related objects?

  1. Factory Method

  2. Singleton

  3. Strategy

  4. Abstract Factory

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The Abstract Factory pattern provides an interface for creating families of related objects without specifying their concrete classes.

Multiple choice

Which design pattern is commonly used to implement the Observer pattern?

  1. Adapter

  2. Composite

  3. Decorator

  4. Publisher-Subscriber

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The Publisher-Subscriber pattern defines a one-to-many dependency between objects, where one object (publisher) notifies multiple objects (subscribers) about changes in its state.

Multiple choice

Which design pattern is used to provide a unified interface to a set of related classes?

  1. Facade

  2. Proxy

  3. Adapter

  4. Composite

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The Facade pattern provides a unified interface to a set of related classes, simplifying their use and reducing coupling.

Multiple choice

Which design pattern is commonly used to implement the Singleton pattern?

  1. Factory Method

  2. Singleton

  3. Strategy

  4. Abstract Factory

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The Singleton pattern ensures that a class has only one instance and provides a global point of access to that instance.