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
-
PasswordDeriveBytes
-
RandomNumberGenerator
-
DeriveBytes
-
CSP Parameters
-
CngKeyBlobFormat
C
Correct answer
Explanation
This .NET cryptographic class represents the abstract base class from which all classes that derive byte sequences of a specified length inherit.
-
ECDiffieHellman
-
ECDiffieHellmanPublicKey
-
ECDiffieHellmanCng
-
ECDSA
-
ProtectedData
A
Correct answer
Explanation
It provides a CNG implementation of the ECDH algorithm implementation can derive form.
-
HashAlgorithm
-
KeyedHashAlgorithm
-
CngAlgorithm
-
CngKey
-
ProtectedData
A
Correct answer
Explanation
This .NET cryptographic class represents the super class from which all implementations of cryptographic hash algorithms must derive.
-
class
-
method
-
interface
-
none of the above
C
Correct answer
Explanation
Runnable is a functional interface in Java that contains a single abstract method run(). Any class implementing Runnable must provide an implementation for the run() method, making it suitable for multithreading. The other options are incorrect because Runnable is not a class, method, or abstract concept - it's specifically an interface designed for thread execution.
-
java.security package
-
java.util package
-
java.io package
-
java.lang package
D
Correct answer
Explanation
Wrapper classes like Integer, Double, Float, Character, and Boolean are part of the java.lang package, which is automatically imported in every Java program. These classes wrap primitive data types to allow them to be used as objects. The java.security, java.util, and java.io packages serve different purposes - security utilities, collections framework, and I/O operations respectively.
-
java.io
-
java.util
-
java.utility
-
java.date
B
Correct answer
Explanation
The Date class is part of the java.util package, which contains utility classes and collections framework. While Date has been largely superseded by the newer java.time API in modern Java, it remains in java.util for backward compatibility. The other options like java.utility, java.date, or java.io are incorrect - Date has never been in those packages.
-
java.util
-
java.io
-
java.utility
-
java.math
A
Correct answer
Explanation
The Random class is part of java.util package and is used for generating pseudorandom numbers. It provides methods like nextInt(), nextDouble(), nextBoolean(), and nextFloat() for various random number types. This is different from Math.random() which returns a double value. Random is not in java.io, java.utility (doesn't exist), or java.math packages.
-
Static keyword is used to preserve the value of a variable.
-
Member functions of a class can also be declared as constants.
-
The local class has no access permission to global variables as well as static variables.
-
Both 1 and 3
-
Both 1 and 2
E
Correct answer
Explanation
Both 1 and 2 are true. So, this is the correct option.
-
A virtual function must not be static.
-
Destructor cannot be declared as virtual, but constructor can be declared as virtual.
-
A virtual function may be declared as a friend for another class.
-
Both 1 and 2
-
Both 1 and 3
E
Correct answer
Explanation
Options 1 and 3 are correct. Option 2 is not correct because destructor can be declared as virtual, but constructor cannot be declared as virtual.
-
Inline function
-
Static function
-
Friend function
-
Virtual function
-
Global function
C
Correct answer
Explanation
This type of function is not in the scope of the class to which it has been declared.
-
Structure
-
Typedef
-
Enumeration
-
Union
-
Class
B
Correct answer
Explanation
This user defined type in C++ is used to give new names to existing data type and allows the user to declare an identifier to represent an existing data type.
-
data abstraction
-
encapsulation
-
inheritance
-
class
B
Correct answer
Explanation
Encapsulation is the packing of data that functions in to a single component.
-
ECDiffieHellmanCngPublicKey
-
ECDiffieHellmanCng
-
ECDiffieHellmanPublicKey
-
ECDiffieHellman
-
ProtectedData
C
Correct answer
Explanation
This .NET cryptographic class provides an abstract super class from which all ECDiffieHellmanCngPublicKey implementations must inherit.
-
HMACMD5
-
HMAC
-
HMACSHA1
-
ProtectedData
-
HashAlgorithm
B
Correct answer
Explanation
This .Net cryptographic class represents the abstract class from which all implementations of HMAC must derive.