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. MyOuter.MyInner m = new MyOuter.MyInner();

  2. MyOuter.MyInner mi = new MyInner();

  3. MyOuter m = new MyOuter(); MyOuter.MyInner mi = m.new MyOuter.MyInner();

  4. MyInner mi = new MyOuter.MyInner();

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

For a static nested class, you use the fully qualified name with both outer and inner class names: 'new MyOuter.MyInner()'. Option B is missing 'MyOuter.' prefix. Option C incorrectly uses 'm.new' syntax (used for non-static inner classes). Option D is missing 'MyOuter.' prefix.

Multiple choice technology
  1. Unix command line interface

  2. System dll

  3. APT_dump

  4. APT_Operator

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

OSH (Orchestrate Shell) operators in DataStage are instances of C++ classes that inherit from the APT_Operator base class. This base class provides the framework for all operator functionality. APT_dump is a debugging tool. The OSH operators are not related to Unix CLI or system DLLs.

Multiple choice technology mainframe
  1. Directed Inheritance

  2. Pattern Inheritance

  3. Class Inheritance

  4. Genetic Inheritance

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

In PegaRULES Process Commander, pattern inheritance relies on alphabetical class naming where classes inherit from parent classes that match their name pattern. The Class Explorer's alphabetical view reveals this pattern inheritance structure. Direct inheritance follows explicit parent-child relationships instead.

Multiple choice technology testing
  1. True

  2. False

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

Object Identification is a mechanism for uniquely identifying objects based on their properties during test recording and playback. It is not designed to retrieve runtime property values - that purpose is served by specific methods like GetROProperty. Object Identification focuses on property-based object recognition, not runtime value extraction.

Multiple choice technology packaged enterprise solutions
  1. System creates private ruleset automaticaly when needed

  2. instance of the Rule-Ruleset-Name class exists for a private RuleSet

  3. name of this RuleSet is the same as their Operator ID

  4. None

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

A private ruleset (used for personal checkouts) is automatically managed by the system. Crucially, no actual Rule-Ruleset-Name instance is created in the database for a private ruleset, making the statement false and therefore the correct answer.

Multiple choice technology programming languages
  1. static

  2. non-static

  3. special-mixed type

  4. not-defined

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

Constructors in Java are not classified as static or non-static methods. They are a special type of block that initializes objects and have no explicit type-access modifier classification. While they behave like instance methods (they run on object creation), they are not technically methods and don't fit into the static/non-static binary.

Multiple choice technology programming languages
  1. Data Shadowing

  2. Data Over-riding

  3. Data Obscuring

  4. None of the Above

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

In Java, declaring a field in a subclass with the same name as an inherited field in the superclass is called field hiding (or variable hiding). Since field hiding is not listed among the options, 'None of the Above' is correct, as overriding only applies to methods.

Multiple choice technology programming languages
  1. True

  2. False

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

Top-level classes in Java cannot be declared static. However, nested classes (inner classes) inside another class can be declared as static. Static nested classes are different from inner classes - they don't have access to instance members of the enclosing class.

Multiple choice technology programming languages
  1. True

  2. False

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

Static inner classes (nested static classes) behave like regular classes - their members are NOT static by default. They can have both instance and static members, just like any other Java class. The 'static' keyword on the class only means it doesn't require an instance of the enclosing class.

Multiple choice technology programming languages
  1. True

  2. False

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

Anonymous inner classes can be created within interfaces in specific contexts. While interfaces cannot have instance initializers, anonymous classes can be defined inside static contexts like static field initialization or static blocks within the interface. This is a valid though rarely used Java feature.