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
-
Plugins
-
Shared Library
-
Linker
-
Binary object file
-
Static library
E
Correct answer
Explanation
It is built in such a way that the link editor will in corporate a copy of only those object files that hold the functions and data referenced in the program into the executable at link time.
-
It manages code execution.
-
It allows you to debug your application and trace the execution of the code.
-
It provides marshalling to and from COM.
-
It prevents the unsafe casts.
-
None of the above
E
Correct answer
Explanation
None of the above are the task of class loader. A class loader is responsible for managing the metadata and loading of the classes.
-
Garbage collection.
-
Support for custom attributes.
-
Support for explicit free threading that allows creation of multithreaded, scalable applications.
-
All of the above
-
Only (1) and (3)
-
Encapsulates data structures
-
Represent base data types and exceptions
-
Perform I/O
-
All of the above
-
Both (1) and (2)
D
Correct answer
Explanation
All are the functions of types in .Net framework.
-
Classes
-
Structures
-
Enumeration
-
All of the above
-
Only (1) and (2)
A
Correct answer
Explanation
These are reference type in CTS of .NET framework.
-
Classes
-
Interfaces
-
Enumerations
-
Delegates
-
Unions
E
Correct answer
Explanation
Unions are not a types included in CTS of .Net framework.
-
Abstract
-
Inherits
-
Exported
-
Sealed
-
None of the above
D
Correct answer
Explanation
This property ensures that the class can not be derived form the other class.
-
Sealed
-
Exported
-
Inherits
-
Abstract
-
None of the above
B
Correct answer
Explanation
This property checks that the class is visible outside the assembly in which it is defined.
-
superclass superclassref=new superclass();
-
superclass superclassref=new sublass();
-
subclass subclassref=new subclass();
-
subclass subclassref=new superclass();
-
Any class reference variable cannot reference other class object.
D
Correct answer
Explanation
It is not possible to reference a super class object with the sub class reference variable.
-
Only for the subclass object, memory will be created.
-
Only for the superclass object, memory will be created.
-
Memory for both superclass and subclass will be created and also that memory is referenced by super class reference variable.
-
Memory for both superclass and subclass will be created and also that memory is referenced by subclass reference variable.
-
None of the above
D
Correct answer
Explanation
When subclass object is created memory allocated for superclass object in association with subclass object. So with the subclass reference variable it is possible to access that memory.
-
It is not possible to implement interface in more than one class.
-
An interface should not have any members except abstract methods.
-
It is not possible to have reference variables for interfaces.
-
We cannot create object for interface.
-
If a class implements two interfaces which have the same method names, then the class should implement all the simlar methods in two interfaces twice.
D
Correct answer
Explanation
No, it is not possible to create an object for an interface because it does not have any implemented functions.
-
If the class does not implement serializable interface.
-
If it has transient keyword before it.
-
If it fails to create objects for 'ObjectOutputStream' and 'FileOutputStram'.
-
If it is overridden.
-
If it is static.
-
HashMap
-
Properties
-
Enumeration
-
Dictionary
-
Stack
A
Correct answer
Explanation
HashMap is not legacy class. It was added as a part of collection framework in J2SE 1.2.
-
attributes and name only
-
operations and name only
-
attributes, name and operations
-
either (1) or (2)
C
Correct answer
Explanation
In object-oriented design, objects are defined by three key components: attributes (data/properties), a name (identifier), and operations (methods/behaviors). Attributes store the object's state, operations define what the object can do, and the name identifies it. Options A and B are incomplete, while D incorrectly suggests either is sufficient.
-
Private
-
Static
-
Public
-
Protected
-
None of the above
B
Correct answer
Explanation
Static is modifier, it is not an access specifier.