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. In method overriding, the super class and the subclass have a same method name with the same parameters type.

  2. In method overriding, the superclass and subclass have the same return type.

  3. Overriding is a form of runtime polymorphism in java.

  4. We can override the static methods in java.

  5. All of the above

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

Yes, all of the above are the true statements.

Multiple choice
  1. Object oriented design

  2. Object oriented analysis

  3. Object oriented programming

  4. None of these

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

Object oriented design (OOD) translates the software requirements into specifications for objects and derives class hierarchies from which the objects can be created.

Multiple choice
  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

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

This is the correct answer as there are 3 constructors of ArrayList class in Java Collections, viz. ArrayList(): creates an empty constructor with default initial capacity; ArrayList(c : collection): creates an arraylist from existing collection c; and ArrayList(x int): creates an arraylist with initial capacity x. So, this is the correct answer.

Multiple choice
  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

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

This is the correct answer. There are 4 constructors of Vector class, viz. Vector(): creates a default vector with initial capacity 10; Vector(c : collections): creates a vector from existing collection; Vector(initialcapacity int): creates a vector with specified initial capacity; and Vector(initialcapacity int,increment int): creates a vector with specified initial capacity and increment. So, this is the correct answer.

Multiple choice
  1. entity of the class

  2. instance of the class

  3. attribute of the class

  4. method of the class

  5. function of the class

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

This is the definition of an object. It uses all the properties of the class.