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
-
An class can implement any number of interfaces.
-
An interface contains public and abstract methods.
-
A class can extend more than one abstract class.
-
An interface can not implement other interface.
-
None of the above
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.
-
A final method cannot be overridden.
-
A static method cannot be overridden.
-
A method which is not overriden, cannot be inherited too.
-
All of the above
-
Only (1) and (2)
D
Correct answer
Explanation
Yes, all are the true statements.
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
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.
C
Correct answer
Explanation
This is the correct answer. Character stream class is defined by using two class hierarchies. These classes are Reader class and Writer class.
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
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.
C
Correct answer
Explanation
This is the correct answer. Byte stream can be defined by using two class hierarchies. These two classes are Input Stream and Ouput Stream.
-
ObjectOutputStream
-
PipedOutputStream
-
ByteOutputStream
-
Both 1 and 2
-
All of these
D
Correct answer
Explanation
Both the options 1 &and2 are correct. So this is the correct choice.
D
Correct answer
Explanation
This is the correct answer. Streams can be used to input and output the data. These are of two types -
Byte Stream - For handling binary data
Character Stream - For handling data such as sequence of characters
-
DatagramPacket class
-
StackFrame class
-
InetAddress class
-
URLConnection class
-
Events
C
Correct answer
Explanation
This class in java.net package makes objects able to manipulated within other network classes.
-
Constructor
-
Destructor
-
Delete operator
-
Friend
-
Member
B
Correct answer
Explanation
Destructor is a special member function that is automatically called whenever an object of the class is destroyed.
-
Object
-
Class
-
Inheritence
-
Pointer
-
Polymorphism
D
Correct answer
Explanation
It is not an OOPs concept.
-
: [Colon operator]
-
:: [Scope resolution operator]
-
. [Dot operator]
-
-> [Arrow operator]
-
& [Reference operator]
B
Correct answer
Explanation
This operator is used to access a global object or global data or static data member.
-
Class A : public B, public C
-
Class A : public B, class C
-
Class A : public B, C
-
Class A : public B public C
-
Class A : B C
A
Correct answer
Explanation
This is the correct declaration according to syntax rule.