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

Multiple choice
  1. It is an operator.

  2. It is a keyword.

  3. It is an interface.

  4. None of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

'instanceof' is an operator, which is used to know the type of an object during runtime.

Multiple choice
  1. Default

  2. Public

  3. Protected

  4. Private

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Return type of finalize() method is protected and this method is called by the garbage collector on an object, when garbage collection determines that there are no more references to the object.

Multiple choice
  1. 9

  2. 8

  3. 7

  4. 6

  5. 5

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This is the correct answer. There are 7 subclasses of the InputStream class. These are:

  1. FileInputStream for reading bytes from a file.
  2. ObjectInputStream for readin objects and primitive data types from input stream.
  3. SequenceInputStream for readin from a sequence of streams.
  4. ByteArrayInputStream for Stream that reads a byte array.
  5. pipedInputStream for reading from a piped stream.
  6. FilterInputStream for filtering input from Existing Stream.
  7. StringBufferInputStream for reading from a string.
Multiple choice
  1. 9

  2. 6

  3. 5

  4. 8

  5. 7

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

There five subclasses of the OutputStream class are:

  1. FileOutputStream for writing bytes into file
  2. ObjectOutputStream for writing objects and primitive data types to output stream.
  3. ByteArrayOutputStream for output stream that writes byte into array.
  4. pipedOutputStream for writing into a piped stream.
  5. FilterOutputStream for filtering output into an existing stream. So, this is the correct answer.
Multiple choice
  1. 9

  2. 8

  3. 7

  4. 6

  5. 5

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

There are 6 subclasses of reader Class in Java. These are:

  1. BufferedReader for buffering other readers
  2. ChararrayReader for reading from char array
  3. FilterReader for reading filter streams
  4. InputStreamReader for reading a character stream
  5. PipedReader for reading from pipe
  6. StringReader for reading from a string So, this is the correct answer.
Multiple choice
  1. 7

  2. 6

  3. 8

  4. 9

  5. 5

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

There are 7 subclasses of the 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.