Computer Knowledge

Object-Oriented Programming

2,239 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. An instance of the Student class

  2. The course variable

  3. The gradeStudent method

  4. The ID variable

  5. The name variable

Reveal answer Fill a bubble to check yourself
B,C,D,E Correct answer
Explanation

In Java inheritance, a subclass inherits all accessible instance variables (name, ID, course) and methods (gradeStudent) from its superclass. It does not inherit an instance - that's not how inheritance works.

Multiple choice technology programming languages
  1. mMemberAttribute

  2. mmemberAttribute

  3. MemberAttribute

  4. member_attribute

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

mMemberAttribute follows the class attribute guideline - 'm' prefix indicates member variable, followed by camelCase. mmemberAttribute (double m), MemberAttribute (no prefix), and member_attribute (snake_case) all violate the naming convention.

Multiple choice technology architecture
  1. DataMemberAttribute, Public

  2. ServiceContractAttribute, Public

  3. DataMemberAttribute,Private

  4. DataContractAttribute,Public

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

DataContractSerializer serializes members marked with DataMemberAttribute regardless of access level (public or private). XmlSerializer only serializes public members by default. This is a key distinction - DataContract gives you more control over what gets serialized, while XmlSerializer follows traditional .NET serialization patterns.

Multiple choice technology web technology
  1. Inversion Injection

  2. Dependency Injection

  3. Setter Injection

  4. Pattern Injection

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

Inversion of Control (IoC) is a design principle where the flow of control is inverted compared to traditional programming. Dependency Injection is a common implementation pattern for achieving IoC - dependencies are provided to objects rather than objects creating them. Setter Injection and Constructor Injection are specific types of Dependency Injection.

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