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
-
Extern
-
Auto
-
Register
-
Volatile
D
Correct answer
Explanation
Volatile is not a storage class specifier. However, it is a qualifier which tells the compiler that variables may be changed in ways not explicitly specified by the program.
-
Virtual functions
-
Strings
-
Templates
-
Operator overloading
C
Correct answer
Explanation
Templates are used to implement generic programming. They are of two types: function templates and class templates. Function templates are methods that can operate on any data type and class template can be used to write single code for multiple data types.
-
size of operator
-
scope resolution operator
-
subscript operator
-
none of the above
B
Correct answer
Explanation
Scope is an enclosing context where values and expressions are associated. The scope resolution operator helps to identify and specifies the context to which an identifier refers. Hence, this is the correct answer.
-
C++ classes
-
C classes
-
C++ structures
-
C structures
D
Correct answer
Explanation
POD means plain old data and is used to describe C style structure which contains only data members.This term as used in C++ structures,can contain data members as well as member functions. Hence, this is the incorrect answer.
-
Virtual functions
-
Static functions
-
Friend functions
-
Constructors
C
Correct answer
Explanation
Friend functions are non-member functions which can access all the private and protected members of the class. An example of a friend function is class abc{ private: int f,s; public: friend int sum(abc x);}; Here, sum function can access even private members of class and is defined below -:int sum(abc x){return x.f+x.s;}.
-
Inheritance
-
Polymorphism
-
Encapsulation
-
None of the above
C
Correct answer
Explanation
Encapsulation is a mechanism that binds together code and data which it manipulates and keeps both of them safe from outside interference and misuse. Hence, this is the correct answer.
-
It must contain atleast one pure virtual function.
-
Pointers to abstract class can be created.
-
References to abstract classes can be created.
-
Objects of abstract classes can be created.
D
Correct answer
Explanation
It is not possible to create objects of abstract class as it contains pure virtual function which is not defined. This statement is false. Hence, it is the correct answer.
-
NNTP service
-
Static
-
Get accessor
-
Set accessor
-
Protected
C
Correct answer
Explanation
This accessor's body resembles that of a method and must return a value of the property type.
-
Value type
-
Reference type
-
Anonymous type
-
Static modifier
-
Public
A
Correct answer
Explanation
This type includes the primitive numeric types, enums and structs and also nullable versions of these types.
-
a program
-
an object deck
-
execution
-
a single-line
C
Correct answer
Explanation
A loader is a system utility that takes an object program from secondary storage and places it into the main memory. Its primary role is to ensure the program is correctly positioned and linked so that the CPU can begin processing it. Therefore, the ultimate goal of the loading process is the execution of the program.
-
setCookies()
-
array
-
unset()
-
_construct()
-
_destructor()
D
Correct answer
Explanation
This method makes easier to shift classes inside the class hierarchies.
-
Public
-
Private
-
NULL
-
Static
-
Final
E
Correct answer
Explanation
This keyword allows you to mark methods so that an inheriting class cannot overload them.
-
Assignment operator
-
foreach()
-
_destructor()
-
unset()
-
list()
B
Correct answer
Explanation
You can iterate instances of the class by using this language construct.
-
NULL
-
Final class
-
Abstract class
-
Meta class
-
RemoteStackFrame class
C
Correct answer
Explanation
This class prevents it from instantiated.
-
HMAC verification
-
Strategy pattern
-
Singleton pattern
-
Factory pattern
-
Reflection
B
Correct answer
Explanation
This pattern is used when your programmer's algorithm is interchangeable with different variations of the algorithm.