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
B
Correct answer
Explanation
Property accessibility cannot exceed the accessibility level of its declaring class. For example, if a class is private, you cannot declare a public property within it. This maintains encapsulation and access control principles in object-oriented programming.
-
System
-
System.Base
-
System.objects
-
System.Object
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.
-
static
-
auto
-
mutable
-
register
-
A static member function can access only static member data, static member functions and data and functions outside the class.
-
A static member function can be called, even when a class is not instantiated
-
A static member function cannot be declared virtual
-
A static member function can have access to the 'this' pointer of the class
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.
-
The JDK and SDK holds the same features with different name
-
The JDK forms an extended subset of a SDK
-
The SDK forms an extended subset of a JDK
-
None
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.
-
Picklist values change at runtime
-
Can be bounded or unbounded
-
Derive their values from LOV
-
Based on Picklist Generic Business Component
A
Correct answer
Explanation
The statement 'Picklist values change at runtime' is NOT true for static picklists - static picklists have fixed values that are defined at design time and do not change during application execution. This is what distinguishes them from dynamic picklists. Options B, C, and D are true characteristics of static picklists (they can be bounded/unbounded, derive from List of Values, and are based on Picklist Generic Business Component).
-
Is public
-
Extends Throwable
-
Implements Throwable
-
Is serializable
-
java.object
-
java.io
-
java.lang
-
java.applet
C
Correct answer
Explanation
Java automatically imports java.lang, which contains fundamental classes like String, Object, System, Math, and wrapper classes. All other packages (java.io, java.util, etc.) must be explicitly imported.
B
Correct answer
Explanation
Abstract classes are incomplete templates containing abstract methods, so the compiler prevents direct instantiation using the new keyword.
-
No difference, both are the same
-
An Object maynot have a class definition, but an instance must have a class definition
-
An Object must have a class definition, but an instance may not have a class definition
-
Object and Instance should have different class definitions. It can not be the same.
B
Correct answer
Explanation
In OOP terminology, 'object' is a broader concept - anything with identity, state, and behavior (including anonymous or prototype-based objects). 'Instance' specifically means an object created from a class definition using instantiation. An object may not have a formal class (as in prototype-based languages), but an instance must originate from a class.
-
Interfaces of the same package and other packages
-
Classes of the same package
-
Classes of the same package and other packages
-
Interfaces of the same package
B,D
Correct answer
Explanation
Protected members are accessible within the same package (to both classes and interfaces) and to subclasses in other packages via inheritance. Option C is wrong because it suggests same-class access isn't required.
A
Correct answer
Explanation
QuickTest Professional organizes test objects into classes based on their type and behavior (e.g., Window, WebEdit, Button). This object-oriented classification allows QTP to identify and interact with similar objects consistently across different applications. The class hierarchy is fundamental to QTP's object recognition model.
-
Class
-
Object properties
-
Object values
-
Run time objects
B
Correct answer
Explanation
In QuickTest Professional, the identifying characteristics of an object are called properties. These include attributes like name, class, value, and various other properties that help QTP uniquely identify and interact with the object during test execution. Properties distinguish one object from another in the application.
B
Correct answer
Explanation
Virtual constructors are impossible in C++ because constructing an object requires knowing its exact type at compile-time for memory allocation. Virtual dispatch works through vtables on already-constructed objects, but construction must happen before the object (and vtable) exists. Therefore, constructors cannot be virtual.
-
There is none; they both work as expected
-
They both do nothing.
-
The first will not invoke all myObj destructors
-
It would'nt delete all the memory allocated to the objects
C
Correct answer
Explanation
The delete[] operator is required for arrays because it invokes the destructor for every element in the array. Using plain delete only invokes the destructor for the first element (myObj) and not the remaining 99 objects, causing resource leaks. The pairing must be new[] with delete[] and new with delete.