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
-
multiple inheritance
-
single inheritance
-
multi level inheritance
-
hybrid inheritance
A
Correct answer
Explanation
Multiple inheritance occurs when a class inherits from more than one base class, combining features from multiple parents. Option B (Single) is one base class. Option C (Multi-level) is a chain of inheritance (grandparent -> parent -> child). Option D (Hybrid) combines multiple types of inheritance.
-
overloading
-
overriding
-
data hiding
-
abstraction
A
Correct answer
Explanation
Overloading uses the same method name to denote different operations based on parameter types or count. Option B (Overriding) is changing implementation in derived class with same signature. Data Hiding (Option C) encapsulates private members. Abstraction (Option D) hides implementation details.
-
Data class
-
Base class
-
Abstract class
-
Derived class
C
Correct answer
Explanation
Abstract classes provide method signatures without implementation, requiring derived classes to provide concrete implementations. Option A (Data class) is not a standard OOP term. Option B (Base class) may have full implementations. Option D (Derived class) inherits from others rather than defining signatures.
-
function overloading
-
function overriding
-
both 1 and 2
-
none of these
C
Correct answer
Explanation
Polymorphism can be achieved through both function overloading (compile-time, same name different parameters) and function overriding (runtime, same signature different implementation in derived classes). Options A and B individually are incomplete - both mechanisms achieve polymorphism.
-
Automatic storage class
-
Register storage class
-
Storage structure
-
External storage class
-
The RemoteStackVariable class
D
Correct answer
Explanation
A variable is said to belong to the external storage class, if the validity of the variable is from the point of definition to the rest of the program.
-
Automatic storage class
-
Static storage class
-
Register storage class
-
Storage structure
-
The RemoteStackVariable class
B
Correct answer
Explanation
Static storage class concerns itself with the permanence of the variables.
-
Inheritance
-
Operator overloading
-
Extents
-
Polymorphism
-
Encapsulation
C
Correct answer
Explanation
This is an object in object-oriented databases, which has a type hierarchy and set/subset constraints have been enforced on it.
B
Correct answer
Explanation
This is the correct answer, there are 5 container classes for AWT components. Container classes are used to contain other GUI components.These container classes are :-WindowPanelAppletFrameDialogSo this is the correct answer.
-
Int size
-
String name
-
Int style
-
Int alignment
-
Int Color
A
Correct answer
Explanation
This is the correct answer, we can pass 3 arguments to the constructor of Font Class. These arguments are :-Font(String name, int style, int size)For example :-Font(“SanSerif”, Font.BOLD,20)The third argument specifies the size of the font.So this is the correct answer.
C
Correct answer
Explanation
This is the correct answer, we can pass 3 arguments to the constructor of Font Class. These arguments are :-Font(String name, int style, int size)For example :-Font(“SanSerif”, Font.BOLD,20)So this is the correct answer.
-
Dynamic binding
-
Encapsulation
-
Operator overloading
-
Nesting
-
Polymorphism
B
Correct answer
Explanation
The mechanism to associate code with its data is called encapsulation.
-
Operator overloading
-
Template classes
-
Pointers
-
Destructor function
D
Correct answer
Explanation
Java has replaced the destructor function with a finalize() function.
-
primitive
-
non-numeric
-
non-primitive
-
none of these
C
Correct answer
Explanation
This a derived data type in Java, which mainly consists of Classes, Interface and Arrays.
-
Public
-
Static
-
Void
-
None of these
B
Correct answer
Explanation
This keyword declares the method as one that belongs to the entire class and not a part of any object of the class.
-
Static variables can not be serialized.
-
Static variables can be serialized.
-
Declaring a variable as volatile means that the variable will be shared in multithreaded environment.
-
All of the above
-
Only (1) and (3)
E
Correct answer
Explanation
Yes, these are the true statements.