Computer Knowledge

Object-Oriented Programming

2,239 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. Default members can be accessed only by classes in the same package.

  2. Protected members can be accessed by other classes in the same package only.

  3. A protected member inherited by a subclass from another package is not accessible to any other class in the subclass package, except for the subclasses of the subclass.

  4. Public members cannot be accessed in other packages.

  5. Both (2) and (4)

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

.

Multiple choice
  1. Interface constant declarations of public, static and final are optional in any combination.

  2. An interface can have abstract method only; no concrete methods allowed.

  3. A class implementing an interface can itself be abstract.

  4. A class can implement any number of interfaces.

  5. All of the above

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

.

Multiple choice
  1. The function must have a different name.

  2. The function must be an inline function.

  3. The function must have the same name with different argument and different return type.

  4. The same function must be inherited by another class.

  5. The function must have no return type nor any arguments.

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

This is the condition that must hold to say that a particular function is overloaded in C++.

Multiple choice
  1. void

  2. break

  3. exit

  4. virtual

  5. continue

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

This keyword is used in C++ when two or more objects are derived from a common base class and to prevent multiple copies of the base class being present in an object derived from other derived classes.