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 platforms and products
  1. True

  2. False

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

SetTOProperty only modifies the property values for the current test run session - it is a temporary runtime change. The Object Repository itself is not permanently modified by SetTOProperty. To make permanent changes to the Object Repository, you would need different methods like the Repository automation object model.

Multiple choice technology platforms and products
  1. @baseclass

  2. Top Level class

  3. ClassGroups

  4. work pool

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

In Pega PRPC class hierarchy, work objects can be instantiated from classes derived from Work- base class, as well as from top-level classes. The class hierarchy supports flexible instantiation patterns while maintaining proper inheritance. Top-level classes provide another entry point for creating work objects outside the standard Work- hierarchy.

Multiple choice technology platforms and products
  1. pattern

  2. pattern n direct

  3. oly pattern n not direct

  4. direct is must

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

In Pega, class rules support both pattern inheritance (based on class name naming conventions) and directed inheritance (explicitly specified parent classes) during rule resolution. Therefore, class rules belong to both pattern and direct inheritance rather than only one.

Multiple choice technology security
  1. Java sand box environment provides protection against decompilation

  2. Java is compiled into ELF binaries and cannot be decompiled

  3. Java byte code can always be decompiled, code obfuscators can make the reverse engineering process more time confusing but cannot prevent it

  4. Java is difficult to decompile because the Just-In-Time compiler automatically perform string encryption by default

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

Java compiles to bytecode that retains enough high-level information to be decompiled back into readable source code using tools like JD-Gui, CFR, or Procyon. Code obfuscators (e.g., ProGuard) can rename variables and methods to make reverse engineering more difficult and time-consuming, but they cannot prevent decompilation entirely. Java is not compiled to ELF binaries (option B), and the JIT compiler does not perform string encryption (option D). The sandbox environment protects against malicious runtime behavior, not decompilation (option A).

Multiple choice technology programming languages
  1. Serial

  2. Local

  3. Private

  4. Static

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

Variables declared inside a method are called local variables because they are only accessible within that method's scope. They are created when the method is called and destroyed when it exits. Private and static variables are declared at class level, while 'serial' is not a standard variable scope term.

Multiple choice technology programming languages
  1. Overloading

  2. Overriding

  3. Overridable

  4. Duplexing

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

Method overloading occurs when a class has multiple methods with the same name but different parameter lists (different number, types, or order of parameters). Overriding refers to a subclass providing a specific implementation of a method already defined in its superclass with the same signature.

Multiple choice technology programming languages
  1. Return type

  2. No errors

  3. Formal parameters

  4. Name

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

Constructors in object-oriented programming cannot have a return type, not even 'void'. The code shows 'Public int EmployeeMgmt' which declares a return type of 'int', making it invalid as a constructor. A constructor should be 'public EmployeeMgmt' with no return type specifier.

Multiple choice technology programming languages
  1. it must inherit the properties of the interface

  2. contain the same methods as the interface

  3. create an interface object

  4. all of the above

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

When a class implements an interface, it must inherit all properties the interface defines, contain implementations of all the interface's methods (unless the class is abstract), and you can create objects of the class that implements the interface (though not directly instantiate the interface itself).

Multiple choice technology programming languages
  1. It contain instance variables

  2. It contain constructors

  3. It may extend another class

  4. All of the these

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

Abstract classes in object-oriented programming can contain instance variables (fields), can have constructors (used by subclasses), and can extend another class (single inheritance). Therefore, all three statements A, B, and C are correct features of abstract classes.

Multiple choice technology programming languages
  1. Different parameter data types

  2. Different number of parameters

  3. Different order of parameters

  4. All of these

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

Method overloading in C# allows creating multiple methods with the same name but different signatures. The three valid ways to differentiate signatures are: different parameter data types (int vs string), different number of parameters (1 arg vs 2 args), and different parameter order (string,int vs int,string). All three approaches can be used alone or combined.

Multiple choice technology programming languages
  1. It is available to classes that are within the same assembly and derived from the specified base class.

  2. It is available within the class definition

  3. It is the most permissive access level

  4. It is the least permissive access level

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

In C#, 'protected internal' access means member access is granted to classes derived from the containing class, or classes within the same assembly. However, the stored option description limits this to derived classes within the same assembly, whereas it is actually an OR condition (either derived OR within the same assembly). Since it is still the intended answer and other options are completely wrong, we mark it OK.

Multiple choice technology programming languages
  1. True

  2. False

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

In C#, a class can implement multiple interfaces simultaneously, which enables achieving a form of multiple inheritance (implementation inheritance). This is different from extending multiple classes, which C# does not support. Interfaces provide contracts that a class must fulfill.

Multiple choice technology programming languages
  1. The method is public

  2. The method can be derived

  3. The method is static

  4. The method can be over-ridden

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

The virtual keyword marks a method as able to be overridden in derived classes. It allows the most derived implementation to be called even when referencing the base class (polymorphism). A virtual method is not automatically public (access is separate), not static (static methods cannot be virtual), and "derived" is vague - the key concept is overriding.