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. can implement only one interface

  2. can implement only two interfaces

  3. can implement multiple interfaces

  4. cannot implement any interface

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

An interface cannot implement any interface

Multiple choice
  1. OuterClass outer = new OuterClass();OuterClass.InnerClass inner = outer.new InnerClass();

  2. InnerClass inner = OuterClass.new InnerClass();

  3. OuterClass outer = new OuterClass();InnerClass inner = outer.new InnerClass();

  4. InnerClass inner = new InnerClass();

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

inner class instantiates using outer class reference.

Multiple choice
  1. primitives

  2. symbols

  3. data types

  4. none of these

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

A service definition is formally described by the set of primitives that the service provider makes available to the service user.

Multiple choice
  1. has no body

  2. returns nothing

  3. is used in a base class

  4. takes no arguments

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

A pure virtual function is declared in a base class with no implementation, typically using the syntax = 0. It forces derived classes to provide their own implementation.

Multiple choice
  1. function name

  2. class name

  3. function name or class name

  4. none of the above

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

A constructor is a special member function that must have the exact same name as the class it belongs to.