Computer Knowledge
Object-Oriented Programming
2,686 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
-
ios::exception
-
stdlib::exception
-
std::exception
-
err::exception
C
Correct answer
Explanation
All the exception thrown by the C++ standard library is derived from the std::exception class. The standard exceptions are bad_alloc, bad_cast, bad_exception, bad_typeid.
-
Final
-
Extend
-
Abstract
-
All of these
-
None of these
B
Correct answer
Explanation
Extend keyword is used to drive class from super class.
-
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
-
FileInputStream
-
PipedInputStream
-
FilterInputStream
-
ByteArrayInputStream
C
Correct answer
Explanation
The LineNumberInputStream, DataInputStream, BufferedInputStream, and PushBackInputStream classes are derived from FilterInputStream class.
-
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.