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
-
Abstract keyword
-
Final keyword
-
Extend keyword
-
Either Final keyword or Extend keyword
-
None of these
A
Correct answer
Explanation
Abstract keyword is used to declare classes that defines common properties and behaviour of other classes.
-
is it correct.
-
this is choice 1
-
this is choice 2
-
this is choice 3
-
FirstTh is a simple class.
-
FirstTh is a class that inherits from Thread class.
-
FirstTh is a class that implements from Thread class.
-
FirstTh is a class that implements Runnable interface.
D
Correct answer
Explanation
Here FirstTh must be a class which implements Runnable interface. Because the statements
FirstTh th=new FirstTh();
Thread sm=new Thread(th).start();
Are used to create a thread by implementing Runnable interface.
-
Errors and Exceptions
-
Error and Exceptions
-
Errors and Exception
-
Error and Exception
D
Correct answer
Explanation
There are two sub-classes of a Throwable class:
- Errors
- Exceptions
-
RuntimeExceptions
-
RuntimeException
-
Exception
-
Throwable
B
Correct answer
Explanation
Java has defined a RuntimeException class which is a super-class for all runtime error classes.
-
class
-
data
-
object
-
methods
C
Correct answer
Explanation
The throw statement is used to throw the object type exception.
-
Data
-
Procedures
-
Objects
-
Orientation
C
Correct answer
Explanation
Object-Oriented Programming (OOP) shifts the focus from procedural logic to modeling software around objects that contain both data and the methods to manipulate that data.
-
define
-
super
-
extend
-
class
D
Correct answer
Explanation
In Java, the 'class' keyword is used to define the blueprint for objects.
-
Method
-
Function
-
Procedure
-
Property
A
Correct answer
Explanation
In OOP, a procedure or function defined within a class that describes an action an object can perform is called a method.
-
is always public
-
is always private
-
can be public or private
-
cannot be defined
C
Correct answer
Explanation
Member functions can have different access modifiers, such as public, private, or protected, to control their visibility and accessibility.
-
To build a user interface
-
To initialize a newly created object
-
To free memory
-
to create a sub class
B
Correct answer
Explanation
Constructors are special methods invoked during the creation of an object to initialize its state.
-
Mudularity
-
Inheritance
-
Encapsulation
-
Polymorphism
C
Correct answer
Explanation
Encapsulation is the OOP principle of keeping object details private and providing access only through member functions. This hides internal implementation details and protects data integrity by controlling how external code can interact with an object's state.
-
Yes
-
No
-
Maybe
-
If you force enough
B
Correct answer
Explanation
Abstract classes are incomplete by design and cannot be instantiated directly; they must be extended by a concrete subclass.
-
Dynamic Binding
-
Dynamic Allocation
-
Static Typing
-
Static Allocation
A
Correct answer
Explanation
Polymorphism allows objects to be treated as instances of their parent class, with the specific method implementation determined at runtime through dynamic binding.
-
Method Overriding
-
Method Overloading
-
Method Overbooking
-
Method Overestimating
B
Correct answer
Explanation
Method overloading occurs when multiple methods in the same class share the same name but have different parameter lists.