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
What is the ability of an object to respond to different messages in different ways?
-
Encapsulation
-
Inheritance
-
Polymorphism
-
Abstraction
C
Correct answer
Explanation
Polymorphism is the ability of an object to respond to different messages in different ways.
What is the process of creating a class that is a specialized version of another class?
-
Encapsulation
-
Inheritance
-
Polymorphism
-
Abstraction
B
Correct answer
Explanation
Inheritance is the process of creating a class that is a specialized version of another class.
What is the process of hiding the implementation details of an object from the user?
-
Encapsulation
-
Inheritance
-
Polymorphism
-
Abstraction
D
Correct answer
Explanation
Abstraction is the process of hiding the implementation details of an object from the user.
What is the process of creating a class from an existing class?
-
Encapsulation
-
Inheritance
-
Polymorphism
-
Abstraction
B
Correct answer
Explanation
Inheritance is the process of creating a class from an existing class.
What is the ability of an object to respond to different messages in different ways?
-
Encapsulation
-
Inheritance
-
Polymorphism
-
Abstraction
C
Correct answer
Explanation
Polymorphism is the ability of an object to respond to different messages in different ways.
What is the process of creating a class that is a specialized version of another class?
-
Encapsulation
-
Inheritance
-
Polymorphism
-
Abstraction
B
Correct answer
Explanation
Inheritance is the process of creating a class that is a specialized version of another class.
What is the process of hiding the implementation details of an object from the user?
-
Encapsulation
-
Inheritance
-
Polymorphism
-
Abstraction
D
Correct answer
Explanation
Abstraction is the process of hiding the implementation details of an object from the user.
What is the process of creating a class from an existing class?
-
Encapsulation
-
Inheritance
-
Polymorphism
-
Abstraction
B
Correct answer
Explanation
Inheritance is the process of creating a class from an existing class.
What is the ability of an object to respond to different messages in different ways?
-
Encapsulation
-
Inheritance
-
Polymorphism
-
Abstraction
C
Correct answer
Explanation
Polymorphism is the ability of an object to respond to different messages in different ways.
What is the process of creating a class that is a specialized version of another class?
-
Encapsulation
-
Inheritance
-
Polymorphism
-
Abstraction
B
Correct answer
Explanation
Inheritance is the process of creating a class that is a specialized version of another class.
Which software design pattern is used to provide a uniform interface to a set of related objects?
-
Factory Method
-
Singleton
-
Facade
-
Builder
C
Correct answer
Explanation
The Facade design pattern is used to provide a uniform interface to a set of related objects.
Which design pattern is used to define a family of related objects?
-
Factory Method
-
Singleton
-
Strategy
-
Abstract Factory
D
Correct answer
Explanation
The Abstract Factory pattern provides an interface for creating families of related objects without specifying their concrete classes.
Which design pattern is commonly used to implement the Observer pattern?
-
Adapter
-
Composite
-
Decorator
-
Publisher-Subscriber
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.
Which design pattern is used to provide a unified interface to a set of related classes?
-
Facade
-
Proxy
-
Adapter
-
Composite
A
Correct answer
Explanation
The Facade pattern provides a unified interface to a set of related classes, simplifying their use and reducing coupling.
Which design pattern is commonly used to implement the Singleton pattern?
-
Factory Method
-
Singleton
-
Strategy
-
Abstract Factory
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.