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();

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

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

To instantiate a static nested class from outside its enclosing class, you must qualify the nested class name with the outer class name, using the syntax Outer.Inner obj = new Outer.Inner(). Other options fail due to missing qualifiers.

Multiple choice technology programming languages
  1. True

  2. False

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

Properties can be overridden polymorphically using keywords like virtual (in base class) and override (in derived class). These modifiers apply to the entire property declaration, not to individual accessors.

Multiple choice technology programming languages
  1. True

  2. False

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

In C# and similar languages, a property getter must return a value (cannot be void) because it needs to provide the property's value when accessed. The setter can be void since it just modifies state. This question specifically addresses the getter's return requirement.

Multiple choice technology web 2.0
  1. System

  2. System.Base

  3. System.objects

  4. System.Object

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

In the .NET Framework, System.Object is the ultimate root class from which all other reference and value types directly or indirectly inherit.

Multiple choice technology programming languages
  1. A static member function can access only static member data, static member functions and data and functions outside the class.

  2. A static member function can be called, even when a class is not instantiated

  3. A static member function cannot be declared virtual

  4. A static member function can have access to the 'this' pointer of the class

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

Static member functions don't have a 'this' pointer because they are not bound to any object instance - they belong to the class itself. Options A, B, and C are all true: static functions can only access static members, can be called without instantiating the class, and cannot be virtual.

Multiple choice technology programming languages
  1. The JDK and SDK holds the same features with different name

  2. The JDK forms an extended subset of a SDK

  3. The SDK forms an extended subset of a JDK

  4. None

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

JDK (Java Development Kit) forms an extended subset of SDK (Software Development Kit). In other words, a JDK is a specialized SDK for Java development - it includes the SDK components plus Java-specific tools. The SDK is the broader concept, JDK is specific to Java.