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
-
dynamic binding
-
containership
-
polymorphism
-
inheritance
B
Correct answer
Explanation
The process of containing objects of another class in a class is known as containership.
-
copy constructor
-
parameterized constructor
-
dynamic constructor
-
none of these
B
Correct answer
Explanation
A constructor with arguments is called as parameterized constructor.
-
Operator overloading
-
Function overloading
-
Inheritance
-
None of these
B
Correct answer
Explanation
Function overloading means the use of same function name to perform different tasks.
-
inline function
-
static function
-
friend function
-
none of these
C
Correct answer
Explanation
This is the function which is not in the scope of any class and acts as friend to all classes.
-
Single inheritance
-
Multi-level inheritance
-
Multiple inheritance
-
None of these
C
Correct answer
Explanation
In multiple inheritance, to avoid duplication of inherited members to the derived class, base classes are declared as 'virtual' base class.
-
Protected
-
Private
-
Public
-
None of these
B
Correct answer
Explanation
Private members of a base class cannot be inheriated either by using public or private derivation.
C
Correct answer
Explanation
This is correct choice because the constructor of the Font class takes Three parameters:- First:- first parameter is of String type which specifies the name of the Font. Second:- second parameter is of type int which specifies the style of the font like Font.BOLD. Third:- third parameter is of type int which specifies the size of the font. ExampleFont f1 = new Font(“Serif”, Font.BOLD, 32); So, this option is true.
C
Correct answer
Explanation
This is correct choice because there are 8 primitive data types in Java. These are: ByteShortIntLongDoubleCharFloatBoolean. So, this is correct answer.
-
Default
-
Public
-
Protected
-
Private
-
None of the above
C
Correct answer
Explanation
It is visible to packages and all of its subclasses.
-
Information hiding
-
Ad hoc polymorphism
-
Message passing
-
Coupling
-
Cohesion
D
Correct answer
Explanation
Coupling or dependency is the degree to which each program module relies on each one of the other modules.
-
Categorization
-
Decomposition
-
Aggregation
-
Generalization
-
Repository
D
Correct answer
Explanation
We can reuse the common properties of different classes and form a new class with it.
-
Aggregation
-
Categorization
-
Decomposition
-
Instantiation
-
Repository
D
Correct answer
Explanation
We create different objects from the class using instantiation.
-
Object's identity
-
Static and dynamic binding
-
Object persistence
-
Meta classes
-
None of these
A
Correct answer
Explanation
An object's identity comes into being when the object is created, and continues to represent that object from then on.
-
Unified approach
-
Framework
-
Pattern
-
Unified modelling language
-
Software system
B
Correct answer
Explanation
A framework is a set of cooperating classes that make up a reusable design for a specific class of software.
-
Class
-
Collaboration
-
Use case
-
Active class
-
Interface
E
Correct answer
Explanation
Interface is a collection of operations that specify a service of a class or component, and describes the externally visible behaviour of that element.