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. An class can implement any number of interfaces.

  2. An interface contains public and abstract methods.

  3. A class can extend more than one abstract class.

  4. An interface can not implement other interface.

  5. None of the above

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

This is a false statement as a class can not extend more than one abstract class in java as it is the case of multiple inheritance and java does not support multiple inheritance.

Multiple choice
  1. A final method cannot be overridden.

  2. A static method cannot be overridden.

  3. A method which is not overriden, cannot be inherited too.

  4. All of the above

  5. Only (1) and (2)

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

Yes, all are the true statements.

Multiple choice
  1. 9

  2. 7

  3. 8

  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 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 are five subclasses of OutputStream class.These 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. 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 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

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.