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
-
We declare any function to be static by putting keyword <b style="mso-bidi-font-weight:normal"><i style="mso-bidi-font-style:normal">static before the function declaration in the class.
-
A static member can access all the members of the same class.
-
Static member function is invoked using the class name, instead of object's name
-
None of the above
B
Correct answer
Explanation
This option is correct because given statement is incorrect as static member function can access only static members (functions or variables) of the same class.
-
There is the only one copy of the data member, maintained for the entire class.
-
Its lifetime is same as lifetime of the object of the class
-
Declaration is done within the class definition
-
Definition is given outside the class definition
B
Correct answer
Explanation
This option is correct as the given statement is incorrect because however, static data member is visible within the class but its lifetime is the entire program.
-
RC2
-
RC2CryptoServiceProvider
-
MD5
-
Rijndael
-
Cryptographic hashes
A
Correct answer
Explanation
It represents the base class from which all implementations of the RC2 algorithm must derive.
-
TripleDES
-
TripleDESCryptoServiceProvider
-
SHA512CryptoServiceProvider
-
SHA256
-
ProtectedMemory
B
Correct answer
Explanation
It defines a wrapper object to access the CSP version of the TripleDES algorithm.
-
RSAPKCS1KeyExchangeFormatter
-
PKCS1MaskGeneration method
-
RSAPKCS1SignatureDeformatter
-
RSA
-
ProtectedData
B
Correct answer
Explanation
It computes mask according to PKCS#1 for use by key exchange algorithms.
-
DSACryptoServiceProvider
-
DSASignatureDeformatter
-
DSA
-
DES
-
ProtectedMemory
C
Correct answer
Explanation
It represents the abstract base class from which from which all implementations of the digital signature algorithm must inherit.
-
DES
-
DSACryptoServiceProvider
-
MD5
-
DESCryptoServiceProvider
-
ProtectedMemory
D
Correct answer
Explanation
It defines a wrapper object to access the CSP version of the data encryption standard algorithm.
-
CryptoConfig
-
CngKey
-
CryptographicAttributeObject
-
Rijndael
-
RandomNumberGenerator
C
Correct answer
Explanation
It contains a type and a collection of values associated with that type.
-
CngKey
-
CngKeyCreationParameters
-
CngKeyBlobFormat
-
CryptoConfig
-
ProtectedData
B
Correct answer
Explanation
It contains advanced properties for key creation.
-
CngAlgorithm
-
CngPropertyCollection
-
CngKey
-
CngKeyBlobFormat
-
ProtectedMemory
B
Correct answer
Explanation
It provides a strongly typed collection of cryptography next generation properties.
-
It stores the elements in a sequence.
-
This interface defines the methods by which you can group the elements in a collection of objects.
-
It extends Map interface so that the keys are maintained in ascending order.
-
It describes an element in the form of key-value pair in a map. This is an inner class of Map interface.
-
This interface does not allow duplicate interface.
D
Correct answer
Explanation
This statement is true about Map.Entry interface.
-
Constructors do not have return type.
-
Constructor has the same name as that of the class.
-
Constructors are called automatically upon object creation time.
-
A constructor can be static.
-
A constructor cannot be final.
D
Correct answer
Explanation
No, a constructor cannot be a static. If it is static, then it is accessible within the class only but not by subclass as static variables are class variables.
-
Abstract class cannot be instantiated.
-
Abstract class has both abstract and concrete methods.
-
An abstract class has any public, private or protected members.
-
A Java class can extend only one abstract class.
-
A static method can be abstract in the abstract class.
E
Correct answer
Explanation
No, a static method cannot be overridden by subclasses, so a static method cannot be abstract.
-
Structure
-
Polymorphism
-
Inheritance
-
Template
-
Function overloading
C
Correct answer
Explanation
It is the capability of one class to inherit properties from another class.
-
Virtual function is used to achieve dynamic binding in C++.
-
We cannot instantiate the base class by defining pure virtual function in that class.
-
We cannot create a virtual function without definition inside the base class.
-
Both (2) and (3) are false.
-
None of these
C
Correct answer
Explanation
This is a false statement about virtual function in C++ as we can create a virtual function without defining the base class, which is known as pure virtual function.