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

  2. Two

  3. None

  4. Many

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

A single .NET DLL (assembly) can contain many classes - there is no limit. DLLs are assemblies that can hold multiple types including classes, interfaces, structs, and enums. The organization of classes within a DLL is flexible and depends on the application's architecture needs.

Multiple choice technology web technology
  1. Server-side code

  2. Client-side code

  3. Both A) and B)

  4. None of the above

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

Code-behind files in ASP.NET contain server-side code that executes on the web server, not in the user's browser. This includes event handlers, business logic, and data access code. Client-side code would be in JavaScript or script tags in the .aspx page.

Multiple choice technology programming languages
  1. True

  2. False

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

An abstract class in object-oriented programming can declare constructors. Although you cannot instantiate an abstract class directly using the new keyword, its constructor is executed during the initialization chain of a concrete subclass when the subclass is instantiated, allowing initialization of shared fields.

Multiple choice technology programming languages
  1. List,HashSet

  2. Queue

  3. Stack

  4. LinkedList

  5. All the above

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

Generic classes in C# and other languages include List, HashSet, Queue, Stack, and LinkedList - all of which are type-safe collection classes. These classes allow you to specify the type of elements they will store when you create an instance. Since all the listed options (A, B, C, D) are valid examples of generic classes, 'All the above' is the correct answer.

Multiple choice technology testing
  1. Property Object

  2. Property Name

  3. Property Value

  4. Dynamic Property

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

In QTP/UFT, using Description.Create() instantiates a Properties collection object (often referred to as a Description object or Property Object) that dynamically defines object properties. It is not a single property name, a single property value, or a dynamic property itself.

Multiple choice technology programming languages
  1. True

  2. False

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

In Java and similar object-oriented languages supporting single inheritance, a class can inherit from only one parent class (abstract or concrete) to avoid the diamond problem. However, it can implement multiple interfaces to achieve multiple inheritance of type, making the statement entirely true.

Multiple choice technology web technology
  1. Classes

  2. Methods

  3. Interfaces

  4. Events

  5. All of the above

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

Generics in .NET can be applied to classes (List), methods (generic functions), interfaces (IComparable), delegates (which relate to events), and structs. Since all the listed types can use generics, 'All of the above' is correct.

Multiple choice technology architecture
  1. Data Access Object

  2. Transfer Object

  3. Business Delegate

  4. Adapter

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

The Adapter pattern allows classes with incompatible interfaces to work together by wrapping one object to match another's interface. It converts the interface of a class into another interface clients expect, enabling unrelated classes to collaborate without modifying their source code.

Multiple choice technology programming languages
  1. Hashtable

  2. ArrayList

  3. Heap

  4. Stack

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

VB.Net provides several collection types including Hashtable (key-value pairs), ArrayList (dynamic array), and Stack (LIFO collection). Heap is NOT a collection type in VB.Net or .NET - it's a memory management structure used internally by the runtime, not a class that developers use directly for storing and retrieving data in their applications.

Multiple choice technology programming languages
  1. Using FRIEND Keyword

  2. Using STATIC Keyword

  3. Using SHARED Keyword

  4. NONE

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

In VB.NET, the Shared keyword allows methods (and other members) to be called without creating an instance of the class. This is equivalent to the 'static' keyword in languages like C# or Java. Option A (FRIEND) is an access modifier that controls visibility, not whether an instance is required.

Multiple choice technology programming languages
  1. Casting

  2. DirectCast

  3. InheritenceCast

  4. LevelCasting

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

In VB.NET, DirectCast is used for casting reference types up and down the inheritance hierarchy. It is more efficient than CType when the conversion type is known at compile time because it avoids runtime type checking overhead. Option A is too generic; Options C and D are not valid VB.NET keywords.

Multiple choice technology programming languages
  1. True

  2. False

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

A final class in Java cannot be extended (inherited from). The final keyword prevents subclassing by design. This is used when you want to prevent modification or extension of a class for security, design, or performance reasons.