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
-
default constructor
-
copy constructor
-
constructor overloading
-
parameterized constructor
-
exit()
C
Correct answer
Explanation
When two or more constructor functions with the same name but with different function signatures act in the same class, it is called constructor overloading.
-
Standard Library(SL)
-
Standard Template Library(STL)
-
Standard Class Library(SCL)
-
Standard Class and template Library(SCTL)
C
Correct answer
Explanation
In C++, Standard Template Library(STL) contains the collection of templatised classes and functions.
A
Correct answer
Explanation
Using Run Time Type Identification (RTTI), we can find the exact type of the object using a pointer to the base class.
-
Structure
-
Union
-
Namespace
-
Class
D
Correct answer
Explanation
Name space, a new concept is introduced in C++. Namespace defines a scope of the identifiers that are used in a program.
-
istream class
-
ostream class
-
strstream class
-
istrstream class
D
Correct answer
Explanation
The istrstream class is used to create an object for accessing the streams of bytes from memory.
-
unidirectional
-
bidirectional
-
input
-
output
B
Correct answer
Explanation
The class iostream is derived from the classes istream and ostream to handle bidirectional (that is from both direction) operation on a single stream.
-
istream
-
ostream
-
iostream
-
ios
D
Correct answer
Explanation
The input/output system starts with the base class ios. The istream and ostream are the derived classes of ios.
-
string
-
Strin
-
str
-
character
A
Correct answer
Explanation
The string class is a class with many constructors, member functions and operators to manipulate the string.
-
process to derive a class from Base class
-
a way in which entity behaves in several forms
-
process to hide complexity of a program
-
none of the above
B
Correct answer
Explanation
Polymorphism means 'many forms'. In OOP, it allows objects of different classes to be treated as objects of a common superclass, with each class implementing the same method differently. This is achieved through virtual functions, function overloading, and operator overloading in C++.
-
functions
-
variables
-
classes
-
overloading
C
Correct answer
Explanation
Object-oriented programming is based on the concept of 'objects' which encapsulate data and behavior. Classes are the blueprints/templates for creating objects. While functions and variables exist in procedural programming, and overloading is a feature, classes are the essential foundation that defines a language as object-oriented.
-
For data hiding
-
For declaring classes
-
For memory management
-
For binding the data with functions
A
Correct answer
Explanation
Abstraction hides complex implementation details while exposing only necessary interfaces. This allows developers to work with high-level concepts without understanding underlying complexities, reducing code coupling.
-
It adds graphics to the computer.
-
It binds data and functions.
-
It helps to secure the data.
-
It leads to the code reusability.
D
Correct answer
Explanation
Inheritance allows new classes to acquire properties and methods from existing classes, promoting code reuse. This hierarchical relationship reduces redundancy and enables polymorphic behavior through shared interfaces.
-
run time entity
-
instance of a class
-
combination of data and functions
-
all of the above
D
Correct answer
Explanation
Objects embody three fundamental characteristics: they exist at runtime (not compile time), are instantiations of class blueprints, and encapsulate both state (data) and behavior (methods) into a single unit.
-
hiding of data
-
binding of data with its methods
-
using the features of one class in other classes
-
using a function in different ways
D
Correct answer
Explanation
Polymorphism allows a single interface to represent different underlying forms. A function can behave differently based on the object type it operates on, enabling flexible and extensible code through method overriding and overloading.
-
objects
-
functions
-
classes
-
operators