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
-
(i) and (ii)
-
(i) and (iv)
-
(i), (ii) and (iv)
-
(i), (iii) and (iv)
B
Correct answer
Explanation
Abstraction, encapsulation, and polymorphism are core pillars of OOP. Inheritance is also essential, and polymorphism is typically realized through inheritance.
B
Correct answer
Explanation
In C++, class members are private by default. Struct members are public by default.
A
Correct answer
Explanation
When an object of a class is created, the compiler automatically invokes the appropriate constructor to initialize the object.
B
Correct answer
Explanation
Constructor overloading is a standard feature in C++, allowing multiple constructors with different parameter lists.
B
Correct answer
Explanation
Constructors and destructors do not have a return type, not even void. Declaring them as void is a syntax error in C++.
A
Correct answer
Explanation
A constructor is a special member function that must have the exact same name as the class it belongs to.
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.
C
Correct answer
Explanation
There are five subclasses of OutputStream class are the. 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.
-
ObjectOutputStream
-
PipedOutputStream
-
ByteOutputStream
-
Both 1 and 2
-
All of these
D
Correct answer
Explanation
As I explained both option 1 and 2 are correct. So this is the correct choice.
B
Correct answer
Explanation
This is the correct answer. there are 7 subclasses of InputStream class.hese 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 readin from a string. These are the 7 subclasses. So this is the correct answer.
C
Correct answer
Explanation
This is an incorrect answer. Character stream class is defined by using two class hierarchies. These classes are: 1.) Reader class 2.) Writer class. So this is the incorrect answer.
C
Correct answer
Explanation
This is the correct answer. Byte stream can be defined by using two class hierarchies. These two classes are : 1.) InputStream 2.) OutputStream. So this is the correct answer.
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 readin 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.
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.
-
Extends
-
Implements
-
Throws
-
Statics
D
Correct answer
Explanation
Static is the keyword, not statics.