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. Public

  2. Protected

  3. Private

  4. Default

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

To solve this question, the user needs to know the concept of access modifiers in object-oriented programming and their default level assigned to the members of a class.

Now, let's go through each option and explain why it is right or wrong:

A. Public: This option is incorrect. Public access modifier allows members of a class to be accessible from anywhere in the program. However, it is not the default access level assigned to members of a class.

B. Protected: This option is incorrect. Protected access modifier allows the members of a class to be accessible within the class and its subclasses. However, it is not the default access level assigned to members of a class.

C. Private: This option is correct. Private access modifier allows the members of a class to be accessible within the class only. It is the default access level assigned to the members of a class if no other access modifier is explicitly specified.

D. Default: This option is incorrect. Default access modifier allows the members of a class to be accessible within the package only. It is not the default access level assigned to the members of a class.

The Answer is: C

Multiple choice technology programming languages
  1. Overloading is a dynamic or run-time binding and Overriding is static or compile-time binding

  2. Redefining a function in a friend class is called function overriding while Redefining a function in a derived class is called a overloaded fucntion.

  3. Overloading is a static or compile-time binding and Overriding is dynamic or run-time binding

  4. Redefining a function in a friend class is called function overloading while Redefining a function in a derived class is called as overridden fucnion.

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

Overloading occurs at compile-time when functions with the same name have different parameters. Overriding happens at runtime when a derived class provides a new implementation for a base class virtual function.

Multiple choice technology programming languages
  1. Template class

  2. Function template

  3. Class template

  4. Both a and c

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

A function template in C++ defines a general set of operations that can be applied to various types of data passed as parameters. While a class template defines a family of classes, a function template specifically represents operations (functions). Therefore, 'Both a and c' is incorrect.

Multiple choice technology web technology
  1. Parent Class only

  2. Parent class and all its child classes

  3. Parent class and all its child classes unless explicitly overridden by another access rule

  4. None of the above

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

In role-based access control systems like Pega, access roles defined at a parent class level automatically inherit down to all child classes. This inheritance persists unless explicitly overridden by a more specific access rule defined at the child class level. Other options miss this conditional override.

Multiple choice technology web technology
  1. px

  2. py

  3. A and B

  4. pz

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

In PRPC, pz prefix properties (Pega-provided protected) are read-only and cannot be modified by developers or users. px properties are public and can be modified, while py properties are your custom properties that you can modify. The pz layer is Pega's protected code that shouldn't be altered.

Multiple choice technology web technology
  1. Covered work objects inherit from Cover-Object- class

  2. Ordinary work objects inherit from the Work-Object- class

  3. Folders may contain only one covered work object

  4. Folders may be a work object

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

Ordinary work objects inherit from the Work-Object- base class in PRPC. Covered work objects inherit from Work-Cover- class, not Cover-Object-. Folders can contain multiple covered work objects, and folders themselves are work objects (Work-Folder- class), so options C and D are false.

Multiple choice technology web technology
  1. Same ClassGroup

  2. Same AccessGroup

  3. Same WorkPool

  4. None of the above

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

In Pega's covering feature, both the Cover (parent) and Covered (child) work objects must belong to the same ClassGroup. This requirement ensures proper inheritance and processing rules apply consistently. AccessGroup and WorkPool control different aspects of security and work routing.

Multiple choice technology web technology
  1. Pattern Inheritance

  2. Direct Inheritance

  3. Both

  4. None of the above

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

Direct Inheritance is mandatory when creating a class - every class must specify its direct parent class using direct inheritance. Pattern Inheritance is optional and provides additional fallback mechanisms for rule resolution beyond the direct inheritance chain.

Multiple choice technology web technology
  1. Mico-Finance

  2. Finance-

  3. Mico-Finance-

  4. All of the above

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

Pattern inheritance works by removing the trailing dash segment and moving up the hierarchy. For MICO-Finance-, removing the trailing dash gives Mico-Finance as the pattern inheritance parent. This is how Pega's pattern inheritance algorithm navigates the class structure.

Multiple choice technology web technology
  1. Parent Class only

  2. Parent class and all its child classes

  3. Parent class and all its child classes unless explicitly overridden by another access rule

  4. None of the above

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

In Pega's access control inheritance model, when an access role is specified at a parent class level, it automatically applies to that parent class AND all its child classes throughout the class hierarchy. This cascading inheritance ensures consistent permissions across related classes. However, if a child class has an explicit access rule that overrides the inherited role, the child's specific rule takes precedence for that class.

Multiple choice technology web technology
  1. px

  2. py

  3. A and B

  4. pz

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

Pega property types starting with pz are protected system properties that cannot be modified. Properties starting with px are standard Pega properties that can be modified, and py properties are also editable. The pz prefix designation is specifically reserved for locked, read-only system properties that maintain platform integrity.

Multiple choice technology web technology
  1. Covered work objects inherit from Cover-Object- class

  2. Ordinary work objects inherit from the Work-Object- class

  3. Folders may contain only one covered work object

  4. Folders may be a work object

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

In Pega's class hierarchy, ordinary work objects inherit from the Work-Object- base class, making option B true. Covered work objects inherit from Work-Cover- class, not Cover-Object-. Folders can contain multiple covered work objects, and folders themselves are typically organizing structures rather than work objects.