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
-
Pattern Inheritance
-
Direct Inheritance
-
Both
-
None of the above
B
Correct answer
Explanation
In Pega, every class MUST have a Direct Inheritance specified - it is mandatory. Direct Inheritance defines which class the new class immediately extends (its parent class in the class hierarchy). Pattern Inheritance is optional and only applies if the class name follows pattern conventions. Option B is correct because without Direct Inheritance, a class cannot be created. Option A is not mandatory, option C is incorrect (only Direct Inheritance is required), and option D contradicts the requirement.
-
Covered work objects inherit from Cover-Object- class
-
Ordinary work objects inherit from the Work-Object- class
-
Folders may contain only one covered work object
-
Folders may be a work object
B
Correct answer
Explanation
In PEGA, ordinary work objects inherit from the Work- base class (patterned as Work-Object- in class naming). Covered work objects do not use a separate 'Cover-Object-' class - they are work objects that have a cover relationship with another work object. Folders can contain multiple covered work objects, not just one, and folders themselves are not work objects.
-
a. Parent class should have the model with the same name as child class.
-
b. In Child class model “Call Super Class Model” Should be enabled.
-
c. Pattern inheritance should be enabled
-
d. a and b and c
-
e. b only
-
f. a and b
F
Correct answer
Explanation
Model chaining in Pega requires that the parent class has a model with the same name as the child class model (a), and the child class model has 'Call Super Class Model' enabled (b). Pattern inheritance (c) is a different inheritance mechanism and is not required for model chaining.
B
Correct answer
Explanation
All classes must have directed inheritance EXCEPT @baseclass, which is the ultimate parent and has no parent itself. Pattern inheritance applies to some classes, but directed inheritance is required for all non-root classes.
-
a. They should be in different rule sets since they are 2 distinct classes
-
b. They should be in same rule set
-
c. It’s not a good practice to create flows in cover class
-
d. Always add covered objects from cover
B
Correct answer
Explanation
Work classes and cover classes should be in the same rule set to maintain proper class structure and inheritance. Cover classes are used to group related work objects, and keeping them in the same rule set ensures consistent access and management.
-
a. It overrides properties
-
b. It doesn’t override properties
-
c. Calls super class model if super class modeling enabled
-
d. Use identical names for the model
B
Correct answer
Explanation
Model chaining in Pega DOES override properties in child classes with properties from parent class models. Option B states it doesn't override, which is the false statement the question seeks. Options A, C, and D describe actual behaviors of model chaining.
-
a. Property reference in value field
-
b. Literal Value
-
c. Using Property-Set method
-
d. Calling a Function
-
e. Boolean Expression
A,B,D,E
Correct answer
Explanation
In a Pega Data Model (or Declare Expressions / Model rules like Data Transforms), property initialization can be defined using property references in value fields, literal values, calling functions, or boolean expressions. Property-Set is an activity method, not a model rule initialization option.
-
Data-Operator-Party
-
Data-Party-Operator
-
Party-Data-Operator
-
Party-Operator-Data
A
Correct answer
Explanation
Data-Operator-Party is Pega's standard class for representing operator parties, including originators. The naming pattern follows Pega's class hierarchy convention. Options B, C, and D use incorrect class naming patterns that don't follow Pega conventions.
-
Foo b = a;
-
Foo b = a.clone();
-
Foo b;b=a;
-
-
B
Correct answer
Explanation
Foo b = a.clone() is correct because calling clone() creates a new object with the same contents as the original. Foo b = a (A) only copies the reference, not the object itself. Foo b; b=a (C) is the same as A. Option D is invalid.
-
pyStandard
-
pyDefault
-
pyDefModel
-
pyStdModel
B
Correct answer
Explanation
In Pega PRPC, the pyDefault model is the standard model provided for most concrete classes. It contains default properties and behaviors. pyStandard is not a standard model name, and the other options (pyDefModel, pyStdModel) are not standard Pega model names.
-
Rule-File-Binary.
-
Rule-File-Text
-
Rule-Obj-Binary
-
Rule-Obj-Text
A
Correct answer
Explanation
Rule-File-Binary is the Pega rule type designed to store binary file content such as images (JPG, JPEG), PDFs, and other non-text files. Rule-File-Text is for text files, while Rule-Obj-Binary and Rule-Obj-Text are not standard Pega rule types for file storage.
-
Code-Pega-List
-
Rule-Pega-Obj
-
pxResults
-
The same class as the returned instance
A
Correct answer
Explanation
The Obj-List method returns results in a clipboard page of class Code-Pega-List. This is a standard Pega list class, not Rule-Pega-Obj (used for rule instances) or pxResults (a page name, not a class).
C
Correct answer
Explanation
For a RuleSet with 5 versions, Rule-RuleSet-Name has 1 instance (one name entry) while Rule-RuleSet-Version has 5 instances (one per version like 01-01, 01-02, etc.). The name is shared across versions.
B
Correct answer
Explanation
Not all classes require direct inheritance. Pattern inheritance and directed inheritance can be used separately. @baseclass is the root and has no inheritance, but other classes can inherit through patterns without direct parent specification.