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 programming languages
  1. Exceptions for objects

  2. Objects of classes

  3. Arguments

  4. Errors

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

In exception handling, catching a base class type will catch all derived class exceptions due to polymorphism. This is because a derived class object 'is-a' base class object, so the base class catch block can handle it. This enables handling groups of related exceptions with a single handler.

Multiple choice technology programming languages
  1. Only with a double line between base class & derived classes

  2. A plane line with no shape on either end

  3. A line with an arrow-head pointing in direction of parent or superclass

  4. Diamond shape between classes

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

In UML, association relationships are represented by a line with an arrowhead pointing from the derived class toward the parent or base class. This shows the direction of the relationship. The other options represent different UML concepts - double lines are for implementation, diamond shapes for aggregation/composition.

Multiple choice technology programming languages
  1. An overloaded assignment operator

  2. The copy constructor

  3. A destructor

  4. All of these options

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

Classes using dynamic memory must provide a destructor to free allocated memory and prevent leaks. While copy constructor and assignment operator are also important (Rule of Three), the destructor is essential - it's the only one absolutely required. The question asks 'should be provided' and destructor is the minimum essential.

Multiple choice technology programming languages
  1. Data Encapsulation, Inheritance & Exception handling

  2. Inheritance, Polymorphism & Exception handling

  3. Data Encapsulation, Inheritance & Polymorphism

  4. Overloading, Inheritance & Polymorphism

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

Encapsulation, inheritance, and polymorphism are widely recognized as the three core foundational pillars of Object-Oriented Programming (OOP). Exception handling is a general runtime control flow feature, and method overloading is a specific implementation of compile-time polymorphism rather than a distinct primary pillar.

Multiple choice technology programming languages
  1. Inheritance

  2. Composition

  3. Association

  4. All of these options

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

Association is a relationship between classes where objects interact but neither owns the other, enabling reusability through collaboration. Inheritance and composition are also reusability mechanisms, but the question seems to focus on association as a form of reusability through inter-class collaboration without ownership.

Multiple choice technology programming languages
  1. By using the mutable="false" attribute in the class mapping.

  2. By using the ismutable="false" attribute in the class mapping.

  3. By using the ismutable="no" attribute in the class mapping

  4. None

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

A Hibernate class mapping can be marked as immutable using mutable="false" attribute. This tells Hibernate that instances of this class never change, allowing optimizations. Options B and C use incorrect attribute names - the correct attribute is 'mutable', not 'ismutable'.

Multiple choice technology enterprise content management
  1. Attributes

  2. Methods

  3. Events

  4. All the above

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

In object-oriented programming and type inheritance, a subtype inherits all features from its supertype: attributes (data members), methods (functions), and events (notifications). This comprehensive inheritance ensures the subtype maintains the supertype's complete interface and behavior.

Multiple choice technology platforms and products
  1. 5, 5

  2. 5, 1

  3. 1, 5

  4. 1, 1

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

For a rule set 'XXX' with 5 versions, Rule-RuleSet-Name (the class) has 1 instance (representing the rule set itself), while Rule-RuleSet-Version has 5 instances (one for each version: XXX-01, XXX-02, XXX-03, XXX-04, XXX-05). This is a fundamental PRPC rule versioning concept.

Multiple choice technology platforms and products
  1. I, II, IV, III, V, VII, VI, VIII

  2. I, IV, V, VI, VII, VIII, II, III

  3. I, IV, II, V, VII, III, VI, VIII

  4. I, II, IV, V, VII, III, VI, VIII

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

In Pega class hierarchy creation, you establish the base class first, then build the work class hierarchy before data classes. Work classes (IV-VIII) are created before data classes (II-III) because work objects typically reference data classes. Within work classes, you create from general (PegaRP-Work) to specific (Work-Object, then specialized types like Work-Object-Admin and Work-Project-Inquiry).

Multiple choice technology
  1. Implement encapsulation

  2. Achieve polymorphism in genesys

  3. enable inheritance in rulesets

  4. B & C

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

The parent parameter in the initialisor event enables inheritance (passing configuration from parent to child rulesets) and achieves polymorphism (allowing child rulesets to override or extend parent behavior). Option A (encapsulation) is not directly related to parent parameters. Option C alone is incomplete.

Multiple choice technology databases
  1. Only local or packaged sub programs can be overloaded.

  2. Overloading allows different functions with the same name that differ only in their return types.

  3. Overloading allows different subprograms with the same number, type and order of the parameter.

  4. Overloading allows different subprograms with the same name and same number or type of the parameters.

  5. Overloading allows different subprograms with the same name but different in either number or type or order of parameter.

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

PL/SQL package subprogram overloading allows multiple subprograms (procedures or functions) to share the same name, provided their formal parameters differ in number, data type, or order. Overloading cannot be done based solely on differing return types, and standalone subprograms cannot be overloaded.