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. It determines the relationship between the two objects such as one-to-one, one-to-many etc.

  2. It determines the complexity of the objects after combining them.

  3. It determines the relationship between the objects in a directional line and shows the has-a relationship.

  4. It hides the implementation details of the system.

  5. None of the above

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

This is true about composition and it is the more restrictive form of aggregation.

Multiple choice
  1. TreeMap is the class of Map interface.

  2. HashMap inherits SortedMap interface.

  3. HashMap is not synchronised.

  4. Only (1) and (3) are true.

  5. (1), (2) and (3) all are true.

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

Yes, both the statements are true.

Multiple choice
  1. The wrapper classes do not contain any constructor.

  2. All the methods of a wrapper class are static in nature.

  3. The wrapper class for float is java.lang.Float.

  4. Wrapper classes are contained in java.lang package.

  5. All of the above

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

Yes, all of the above defines the properties of wrapper class in java.

Multiple choice
  1. public > protected > package-private > private

  2. public > protected > private > package-private

  3. public > private > package-private > protected

  4. public > private > protected > package-private

  5. package-private > private > package-private > protected

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

Correct choice

Multiple choice
  1. Private

  2. Public

  3. Protected

  4. Package-private

  5. None of these

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

The default scope is package-private. All classes in the same package can access the method/field/class. Package-private is stricter than protected and public scopes, but more permissive than private scope.

Multiple choice
  1. BootStrap Classloader, Extension Classloader, System Classloader

  2. BootStrap Classloader, System Classloader, Extension Classloader

  3. Extension Classloader, BootStrap Classloader, System Classloader

  4. Extension Classloader, System Classloader, BootStrap Classloader

  5. None of the above

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

BootStrap is the parent class loader, then comes Extension class loader, and then System class loader.

Multiple choice
  1. Static fields are initialized before non static fields.

  2. Non static fields are initialized before static fields.

  3. Both static fields and non static fields are initialized at the same time.

  4. It depends on the JVM.

  5. None of these

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

Static fields are initialized during static initialization of class whereas non static fields are initialized when instance of class is created, so static fields are initialized before non static fields.