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. multiple inheritance

  2. single inheritance

  3. multi level inheritance

  4. hybrid inheritance

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

Multiple inheritance occurs when a class inherits from more than one base class, combining features from multiple parents. Option B (Single) is one base class. Option C (Multi-level) is a chain of inheritance (grandparent -> parent -> child). Option D (Hybrid) combines multiple types of inheritance.

Multiple choice
  1. overloading

  2. overriding

  3. data hiding

  4. abstraction

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

Overloading uses the same method name to denote different operations based on parameter types or count. Option B (Overriding) is changing implementation in derived class with same signature. Data Hiding (Option C) encapsulates private members. Abstraction (Option D) hides implementation details.

Multiple choice
  1. Data class

  2. Base class

  3. Abstract class

  4. Derived class

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

Abstract classes provide method signatures without implementation, requiring derived classes to provide concrete implementations. Option A (Data class) is not a standard OOP term. Option B (Base class) may have full implementations. Option D (Derived class) inherits from others rather than defining signatures.

Multiple choice
  1. function overloading

  2. function overriding

  3. both 1 and 2

  4. none of these

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

Polymorphism can be achieved through both function overloading (compile-time, same name different parameters) and function overriding (runtime, same signature different implementation in derived classes). Options A and B individually are incomplete - both mechanisms achieve polymorphism.

Multiple choice
  1. Automatic storage class

  2. Register storage class

  3. Storage structure

  4. External storage class

  5. The RemoteStackVariable class

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

A variable is said to belong to the external storage class, if the validity of the variable is from the point of definition to the rest of the program.

Multiple choice
  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

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

This is the correct answer, there are 5 container classes for AWT components. Container classes are used to contain other GUI components.These container classes are :-WindowPanelAppletFrameDialogSo this is the correct answer.

Multiple choice
  1. Int size

  2. String name

  3. Int style

  4. Int alignment

  5. Int Color

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

This is the correct answer, we can pass 3 arguments to the constructor of Font Class. These arguments are :-Font(String name, int style, int size)For example :-Font(“SanSerif”, Font.BOLD,20)The third argument specifies the size of the font.So this is the correct answer.

Multiple choice
  1. 5

  2. 4

  3. 3

  4. 2

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

This is the correct answer, we can pass 3 arguments to the constructor of Font Class. These arguments are :-Font(String name, int style, int size)For example :-Font(“SanSerif”, Font.BOLD,20)So this is the correct answer.

Multiple choice
  1. Static variables can not be serialized.

  2. Static variables can be serialized.

  3. Declaring a variable as volatile means that the variable will be shared in multithreaded environment.

  4. All of the above

  5. Only (1) and (3)

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

Yes, these are the true statements.