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
D
Correct answer
Explanation
This is the correct answer. Streams can be used to input and output the data. They are of two types. Byte Stream - for handling binary data. Character Stream - for handling data such as sequence of characters. Thus this is the correct answer.
-
StrBufferedInputStream
-
FilterInputStream
-
SequenceInputStream
-
Both 2 and 3
-
All of these
D
Correct answer
Explanation
This is the correct answer.
-
Nine
-
Six
-
Five
-
Eight
-
Seven
C
Correct answer
Explanation
There are five subclasses of Output Stream class.
These are
1) File Output Stream - for writing bytes into file.
2) Object Output Stream - for writing objects and primitive data types to output stream.
3) Byte Array Output Stream:- For output stream that writes byte into array.
4) piped Output Stream - for writing into a piped stream.
5) Filter Output Stream : for filtering output into an existing stream. So this is an incorrect answer.
-
seven
-
five
-
two
-
four
-
none of these
C
Correct answer
Explanation
Character stream class is defined by using two class hierarchies. These classes are Reader class and Writer class.
-
Seven
-
Six
-
Eight
-
Nine
-
Five
A
Correct answer
Explanation
There are 7 subclasses of Writer class in Java.
These are
1) OutputStreamWrite for writing a character stream
2) BufferedWriter for buffering other writers
3) PrintWriter for writing formatted data
4) PipedWriter for writing to a pipe
5) CharArrayWriter for writing to a char array
6) StringWriter for writing to a string
7) FilterWriter for writing filtered streams. So this is the correct answer.
-
Nine
-
Seven
-
Eight
-
Six
-
Five
B
Correct answer
Explanation
There are seven subclasses of InputStream class.
These are
1) FileInputStream for reading bytes from a file
2) ObjectInputStream for reading objects and primitive data types from input stream
3) SequenceInputStream for reading from a sequence of streams
4) ByteArrayInputStream for a stream that reads a byte array
5) pipedInputStream for reading from a piped stream
6) FilterInputStream for filtering input from the existing Stream
7) StringBufferInputStream for reading from a string.
-
ProtectedMemory
-
RSACrypyoServiceProvider
-
DES
-
RSA
-
DSA
D
Correct answer
Explanation
This .NET cryptographic class represents the super class from which all implementations of the RSA algorithm inherit.
-
RC2CryptoServiceProvider
-
Rijndael
-
RC2
-
MD5
-
ProtectedData
C
Correct answer
Explanation
This .NET cryptographic class represents the super class from which all implementations of the RC2 algorithm must derive.
-
RIPEMD160Managed
-
RIPEMD160
-
RijndaelManagedTransform
-
Rijndael
-
ProtectedMemory
B
Correct answer
Explanation
This .NET cryptographic class represents the abstract class from which all implementations of the MD160 hash algorithm inherit.
-
RSAPKCS1SignatureDeformatter
-
RSAPKCS1KeyExchangeDeformatter
-
RSAPKCS1SignatureFormatter
-
ProtectedData
-
AsymmetricSignatureDeformatter
A
Correct answer
Explanation
This .NET cryptographic class verifies an RSA PKCS#1 version 1.5 signature.
-
RSAPKCS1KeyExchangeFormatter
-
RSAPKCS1KeyExchangeDeformatter
-
RSAOAEPKeyExchangeDeformatter
-
AsymmetricKeyExchangeFormatter
-
ProtectedMemory
A
Correct answer
Explanation
This .NET cryptographic class creates the PKCS#1 key exchange data using RSA.
-
ProtectedData
-
DeriveBytes
-
RNGCryptoServiceProvider
-
RandomNumberGenerator
-
MaskGeneration
D
Correct answer
Explanation
This .NET cryptographic class represents the abstract class from which all implementations of cryptographic random number generators derive.
B
Correct answer
Explanation
This is the 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 answer is correct because there are 8 primitive data types in java. These are ByteShortIntLongDoubleCharFloatBoolean.
-
A posing class can call overridden methods through super keyword.
-
The posing class must not define any new instance variables other than target class.
-
A posing class can not override methods defined in the categories.
-
The target class is unaware of any information about posing class.
-
A class may only pose as one of its direct or indirect super classes.
C
Correct answer
Explanation
A posing class can override methods defined in categories.