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
Abstract classes are designed to be incomplete and cannot be directly instantiated using the 'new' keyword. They serve as templates for subclasses and must be extended before their functionality can be used. Only concrete subclasses of abstract classes can be instantiated.
-
base
-
java. lang
-
object
-
system
-
Byte Set
-
Bit Sets
-
Byte Sets
-
Bit Set
A
Correct answer
Explanation
In Java, applets can extend either the Applet class (from AWT) or the JApplet class (from Swing). JApplet is the Swing alternative to AWT's Applet class, providing the same functionality with Swing's improved UI components and capabilities.
A
Correct answer
Explanation
An abstract class can be used to partially implement an interface. The abstract class provides implementations for some methods while leaving others abstract, forcing concrete subclasses to implement the remaining interface methods.
-
Overriding
-
Multi threading
-
Overloading
-
Copying
-
interface
-
child class
-
base class
-
listener
C
Correct answer
Explanation
The 'extends' keyword in Java is used for inheritance and is always followed by the base class (parent class) name. The child class inherits properties and behaviors from the base class, establishing an 'is-a' relationship between them.
-
base ()
-
parent ()
-
super ()
-
none of the above
C
Correct answer
Explanation
The super() call is used in Java to invoke the constructor of the base (parent) class from a child class constructor. This allows the child class to initialize inherited properties and behaviors defined in the parent class, ensuring proper initialization throughout the inheritance chain.
-
Automatic storage class
-
Storage structure
-
The Remote Stack Variable class
-
Static storage class
-
The Content Handler class
D
Correct answer
Explanation
This storage class concerns itself with the permanence of variables.
-
Automatic storage class
-
Storage structure
-
The remote stack frame class
-
The remote stack variable class
-
External storage class
E
Correct answer
Explanation
In this storage class, the variables are created when the program is run and destroyed when the program is exited.
-
protected
-
public
-
private
-
static
-
is not allowed
-
cannot have a constructor
-
cannot have a destructor
-
cannot be passed as an argument
-
Class
-
Inheritance
-
Polymorphism
-
Aggregation
A
Correct answer
Explanation
A class serves as a blueprint or template that defines the structure and behavior common to all objects of that type. It specifies what data (variables/attributes) and operations (methods/functions) every object created from that class will have. Objects are instances created from this blueprint.
-
method overloading
-
method invocating
-
method overriding
-
method labeling
A
Correct answer
Explanation
Method overloading allows a class to have multiple methods with the same name but different parameter lists (different number or types of parameters). The compiler selects which version to call based on the arguments passed. This is different from overriding (replacing a parent class method) and enables method behavior to vary based on input types.
-
III and IV
-
I and II
-
II and III
-
I and IV
C
Correct answer
Explanation
Constructors have the same name as their class (statement II is true) and can be overloaded to provide multiple initialization options (statement III is true). Statement I is false because while constructors have no return type, they are not void methods. Statement IV is false because constructors are called automatically during object creation, not like regular methods.