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 web technology
  1. True

  2. False

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

Object diagrams show specific instances of classes with their actual attribute values at a given moment. While class diagrams define the structure and relationships, object diagrams require runtime state information and specific instance data that cannot be derived from class definitions alone. You need to know what objects actually exist and their current state to create an object diagram.

Multiple choice technology programming languages
  1. Interface

  2. Class

  3. Abstract Class

  4. Filter

  5. None

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

GenericServlet is an abstract class in the Java Servlet API, not an interface or concrete class. It implements the Servlet interface and provides basic implementations for most methods, except service() which remains abstract. Subclasses must implement service().

Multiple choice technology programming languages
  1. Interface

  2. Class

  3. Abstract Class

  4. All

  5. None

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

Abstract classes can have both abstract methods (without implementation) and concrete methods (with implementation). This allows partial implementation - some methods are implemented, others are left abstract for subclasses to implement. Interfaces require all methods to be implemented by the implementing class, and concrete classes must provide complete implementation.

Multiple choice technology programming languages
  1. Interface

  2. Class

  3. Abstract Class

  4. Filter

  5. None

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

GenericServlet is an abstract class in Java Servlet API that implements the Servlet interface. It provides basic implementation of most Servlet methods except service(), which must be implemented by subclasses. HttpServlet extends GenericServlet to provide HTTP-specific functionality. GenericServlet is not an interface, not a concrete class, and not a Filter.

Multiple choice technology programming languages
  1. Interface

  2. Class

  3. Abstract Class

  4. All

  5. None

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

Abstract classes are designed specifically to provide partial implementation - they can have both abstract methods (without implementation) and concrete methods (with implementation). Interfaces require all methods to be implemented (before Java 8) and regular classes must provide complete implementations. Only abstract classes allow the flexibility of implementing some methods while leaving others for subclasses to complete.

Multiple choice technology platforms and products
  1. Can create instances of concrete classes

  2. Must have patterns & direct inheritance

  3. Must have direct inheritance and need not have pattern inheritance.

  4. Need not have either pattern or direct inheritance

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

Concrete classes in Pega are classes from which instances can be created (option A is correct). They must have direct inheritance (a parent class) but are not required to have pattern inheritance (option C is correct). Pattern inheritance is optional for concrete classes, so they need not have it (making C correct, not B). Option D is incorrect because they must have at least direct inheritance.

Multiple choice technology platforms and products
  1. Work-

  2. .@baseclass

  3. Class group

  4. None of the above

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

In Pega, the Class Group (work pool) container is responsible for defining the key structure (typically pyID) and mapping instantiated work objects of its member classes to a single database table. 'Work-' and '.@baseclass' are base classes, not key definitions.

Multiple choice technology architecture
  1. (a) Code-Pega-List

  2. (b) Rule-Pega-Obj

  3. (c) pxResults

  4. (d) The same class as the returned instance

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

The Obj-List method creates a top-level clipboard page with class Code-Pega-List. This class contains query results. Rule-Pega-Obj is for individual rule instances, pxResults is a property name within the list page, and the class is not the same as the returned instance class.

Multiple choice technology architecture
  1. (a) Code-Pega-List

  2. (b) Rule-Pega-Obj

  3. (c) pxResults

  4. (d) The same class as the returned instance

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

Obj-List always creates a top-level clipboard page of class Code-Pega-List, which contains the results of the database query. The pxResults mentioned in option C is actually a property within that page, not the class itself. Code-Pega-List is Pega's standard class for list-type results.

Multiple choice technology programming languages
  1. List<string>

  2. IEnumerable<string>

  3. List<object>

  4. IEnumerable<object>

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

The Where() extension method on List returns IEnumerable, the deferred execution sequence interface. This is the standard LINQ return type for filtering operations. The actual runtime type is a nested iterator class, but the declared return type is IEnumerable. It is not List or the object variant.

Multiple choice technology programming languages
  1. True

  2. False

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

Static methods belong to the class itself, not to any specific instance. They can only access static variables (class variables) and cannot directly reference instance variables, which require an object instance to exist. This is a fundamental Java concept regarding method types and variable scope.

Multiple choice technology web technology
  1. Two methods defined in that interface

  2. Only certain methods in an interface

  3. Any methods in a class

  4. All methods defined in that interface

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

When a class implements an interface, it enters a contract to provide concrete implementations for ALL methods declared in that interface. This is a fundamental Java principle - interfaces define what a class MUST do, and the implementing class provides the specific behavior for every method.

Multiple choice technology programming languages
  1. To avoid having to declare variables

  2. To refer to a class without using prefixes

  3. To avoid calling methods

  4. To import the images you want to use

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

Import statements allow you to reference classes by their simple names instead of using fully qualified names with package prefixes. This improves code readability and reduces verbosity - instead of writing 'java.util.ArrayList' repeatedly, you can import it once and use 'ArrayList' throughout your code.

Multiple choice technology web technology
  1. True

  2. False

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

Objects referenced by CompoundPropertyModel should ideally be Serializable to support session replication, clustering, and other scenarios where the session may be serialized. However, Wicket does not strictly enforce this for basic operation, so the answer is False - it's recommended but not required.