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. Only (a)

  2. Only (a) and (b)

  3. Only (b) and (c)

  4. All (a), (b) and (c)

  5. None of the above

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

All a,b and c are correct.

Multiple choice
  1. Used for inheritance

  2. Allows child class to call parameterized constructor of the class

  3. Used for making a function inline

  4. Used for making class or function template

  5. Allows parent class to call parameterized constructor of child class

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

In constructor calling, default constructor of parent class gets automatically called. Super keyword allows child class to call parameterized constructor of the parent class.

Multiple choice
  1. Only (a)

  2. Only (a) and (b)

  3. Only (b) and (c)

  4. All (a), (b) and (c)

  5. None of the above

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

None of the above s correct answer as all a,b,c are the differences between interface and abstract class.

Multiple choice
  1. Using static modifier

  2. Using private access specifier

  3. Using final modifier

  4. Using volatile modifier

  5. None of these

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

Final modifier can be used with class, data member and methods. A class cannot be inherited when declared as final.

Multiple choice
  1. They can only call static methods.

  2. They must only access static data.

  3. They cannot refer to 'this' keyword.

  4. They cannot refer to 'super' keyword.

  5. Static data cannot be initialized.

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

This is not the correct restriction as static data can be initialized to any value.

Multiple choice
  1. Child class

  2. Subclass

  3. Derived class

  4. Parent class

  5. Array class

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

A parent class is the closest class that we derive to create the one we are referencing as the child class.