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. Nine

  2. Six

  3. Five

  4. Eight

  5. Seven

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Seven

  2. Six

  3. Eight

  4. Nine

  5. Five

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Nine

  2. Seven

  3. Eight

  4. Six

  5. Five

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. 4

  2. 3

  3. 2

  4. 1

  5. None of these

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. A posing class can call overridden methods through super keyword.

  2. The posing class must not define any new instance variables other than target class.

  3. A posing class can not override methods defined in the categories.

  4. The target class is unaware of any information about posing class.

  5. A class may only pose as one of its direct or indirect super classes.

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

A posing class can override methods defined in categories.