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
A
Correct answer
Explanation
A constructor can be without a parameter also. The constructor without any parameter is called a default constructor.
-
Simple inheritance
-
Multilevel inheritance
-
Multiple inheritance
-
Hierarchical inheritance
A
Correct answer
Explanation
The given structure is a representation of simple inheritance.

-
Simple inheritance
-
Multilevel inheritance
-
Multiple inheritance
-
Hierarchical inheritance
B
Correct answer
Explanation
The given structure is a representation of multilevel inheritance.

-
classes
-
interfaces
-
structures
-
static methods
B
Correct answer
Explanation
Multiple inheritance can be implemented in Java using interfaces. One or more classes can implement the defined interface.
-
public
-
private
-
abstract
-
final
D
Correct answer
Explanation
A final class cannot be extended. If we try the compiler will give an error.
-
{
}
class B
{
}
class C implements A,B
{
}|
-
{
}
class B
{
}
class C implement A,B
{
}|
-
{
}
class B
{
}
class C extends A,B
{
}|
-
{
}
class B
{
}
class C extend A,B
{
}|
A
Correct answer
Explanation
The implementation in Java for the given structure is as follows:
class A
{
}
class B
{
}
class C implements A,B
{
}
-
A class can extend another class.
-
A class can implement multiple interfaces.
-
A class can extend multiple classes.
-
An interface can extend another interface.
-
A class can extend another class and implement an interface at the same time.
C
Correct answer
Explanation
This is a false statement. Multiple inheritence is not supported in Java.
-
Class
-
Throwable
-
Object
-
String
-
Super
C
Correct answer
Explanation
It is the correct answer. Object is the Super class of all classes in Java.
D
Correct answer
Explanation
There are 8 parameterized constructors defined for a Scanner class.
-
A constructor can be executed simultaneously with the creation of an object.
-
A constructor which is used for one object cannot be used again unless a second object is created.
-
A constructor does not return a value.
-
A constructor cannot be overloaded.
-
A constructor must have the same name as its class.
D
Correct answer
Explanation
Since the statement is true about constructors, it the wrong answer.
Since the statement is not true about constructors, it is the correct answer.
-
class person()
-
talk()
-
person()
-
private int age;
-
none of these
C
Correct answer
Explanation
This is a constructor since the class is also person and the constructors have the same names as that of their classes. It is wrongly defined in the program as void is used before constructor which is not allowed.
-
Static methods can be accessed using the class name.
-
Static methods can be accessed directly by writing the method name.
-
Static methods can be accessed using objects of the class, where the static method is defined.
-
Static methods can be accessed using “this”.
A
Correct answer
Explanation
Static methods can be accessed using the class name.
Syntax:
Classname.Static_method();
-
|
| Byte(Byte b1); |
| Byte(String str1); |
-
|
| Byte(int b1); |
| Byte(String str1); |
-
|
| Byte(byte b1); |
| Byte(String str1); |
-
|
| Byte(byte b1); |
| Byte(string str1); |
C
Correct answer
Explanation
There are two constructors for the Byte class.
1. Byte(byte b1);
- Byte(String str1);
-
java.awt
-
java.lang
-
java.math
-
java.net
B
Correct answer
Explanation
The class String is defined in the package java.lang.
-
Collection
-
List
-
Set
-
SortedSet
-
SecurityManager
A
Correct answer
Explanation
This interface enables you to work with a group of objects.