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

  2. Shared Library

  3. Linker

  4. Binary object file

  5. Static library

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. It manages code execution.

  2. It allows you to debug your application and trace the execution of the code.

  3. It provides marshalling to and from COM.

  4. It prevents the unsafe casts.

  5. None of the above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. Garbage collection.

  2. Support for custom attributes.

  3. Support for explicit free threading that allows creation of multithreaded, scalable applications.

  4. All of the above

  5. Only (1) and (3)

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

All the services of CLR.

Multiple choice
  1. superclass superclassref=new superclass();

  2. superclass superclassref=new sublass();

  3. subclass subclassref=new subclass();

  4. subclass subclassref=new superclass();

  5. Any class reference variable cannot reference other class object.

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

It is not possible to reference a super class object with the sub class reference variable.

Multiple choice
  1. Only for the subclass object, memory will be created.

  2. Only for the superclass object, memory will be created.

  3. Memory for both superclass and subclass will be created and also that memory is referenced by super class reference variable.

  4. Memory for both superclass and subclass will be created and also that memory is referenced by subclass reference variable.

  5. None of the above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice
  1. It is not possible to implement interface in more than one class.

  2. An interface should not have any members except abstract methods.

  3. It is not possible to have reference variables for interfaces.

  4. We cannot create object for interface.

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

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

No, it is not possible to create an object for an interface because it does not have any implemented functions.

Multiple choice
  1. If the class does not implement serializable interface.

  2. If it has transient keyword before it.

  3. If it fails to create objects for 'ObjectOutputStream' and 'FileOutputStram'.

  4. If it is overridden.

  5. If it is static.

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

Correct answer.

Multiple choice
  1. attributes and name only

  2. operations and name only

  3. attributes, name and operations

  4. either (1) or (2)

Reveal answer Fill a bubble to check yourself
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.