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 technology packaged enterprise solutions
  1. Picklist values change at runtime

  2. Can be bounded or unbounded

  3. Derive their values from LOV

  4. Based on Picklist Generic Business Component

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

The statement 'Picklist values change at runtime' is NOT true for static picklists - static picklists have fixed values that are defined at design time and do not change during application execution. This is what distinguishes them from dynamic picklists. Options B, C, and D are true characteristics of static picklists (they can be bounded/unbounded, derive from List of Values, and are based on Picklist Generic Business Component).

Multiple choice technology programming languages
  1. No difference, both are the same

  2. An Object maynot have a class definition, but an instance must have a class definition

  3. An Object must have a class definition, but an instance may not have a class definition

  4. Object and Instance should have different class definitions. It can not be the same.

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

In OOP terminology, 'object' is a broader concept - anything with identity, state, and behavior (including anonymous or prototype-based objects). 'Instance' specifically means an object created from a class definition using instantiation. An object may not have a formal class (as in prototype-based languages), but an instance must originate from a class.

Multiple choice technology programming languages
  1. Interfaces of the same package and other packages

  2. Classes of the same package

  3. Classes of the same package and other packages

  4. Interfaces of the same package

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

Protected members are accessible within the same package (to both classes and interfaces) and to subclasses in other packages via inheritance. Option C is wrong because it suggests same-class access isn't required.

Multiple choice technology testing
  1. True

  2. False

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

QuickTest Professional organizes test objects into classes based on their type and behavior (e.g., Window, WebEdit, Button). This object-oriented classification allows QTP to identify and interact with similar objects consistently across different applications. The class hierarchy is fundamental to QTP's object recognition model.

Multiple choice technology testing
  1. Class

  2. Object properties

  3. Object values

  4. Run time objects

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

In QuickTest Professional, the identifying characteristics of an object are called properties. These include attributes like name, class, value, and various other properties that help QTP uniquely identify and interact with the object during test execution. Properties distinguish one object from another in the application.

Multiple choice technology programming languages
  1. True

  2. False

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

Virtual constructors are impossible in C++ because constructing an object requires knowing its exact type at compile-time for memory allocation. Virtual dispatch works through vtables on already-constructed objects, but construction must happen before the object (and vtable) exists. Therefore, constructors cannot be virtual.

Multiple choice technology programming languages
  1. There is none; they both work as expected

  2. They both do nothing.

  3. The first will not invoke all myObj destructors

  4. It would'nt delete all the memory allocated to the objects

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

The delete[] operator is required for arrays because it invokes the destructor for every element in the array. Using plain delete only invokes the destructor for the first element (myObj) and not the remaining 99 objects, causing resource leaks. The pairing must be new[] with delete[] and new with delete.

Multiple choice technology programming languages
  1. Classes in class diagrams may be grouped into packages in order to illustrate the overall organization of a model

  2. In object diagrams, names of instances are in italics or all-caps

  3. If package B depends on package A, then any change in A will require a change in B

  4. Object diagrams and class diagrams are completely interchangeable

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

In UML class diagrams, classes can be grouped into packages to organize the model. Object diagram names are underlined (not italicized), package dependencies do not always force changes, and class/object diagrams are not fully interchangeable.

Multiple choice technology programming languages
  1. methods in the associated classes

  2. subclasses needed to accomplish the same functionality

  3. case statements and conditionals

  4. coupling between classes in the system

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

Polymorphism's key advantage is replacing conditional logic (case/switch statements and if-else chains) with dynamic dispatch through virtual functions. Instead of checking type and executing corresponding code, polymorphism lets each subclass implement its own behavior, invoked through a common interface. This reduces conditional complexity.

Multiple choice technology programming languages
  1. Multiple Inheritance and Overloading

  2. Operator Overloading and Overriding

  3. Multiple Inheritance and Operator Overloading

  4. Pointers and Single Inheritance

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

Java does not support multiple inheritance of classes (to avoid the diamond problem) nor does it support user-defined operator overloading. Therefore, this pair is not supported in Java.