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. Run-time polymorphism

  2. Compile-time polymorphism

  3. Parametric polymorphism

  4. Ad-hoc polymorphism

  5. Abstract class

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

This type of polymorphism is the one in which all code is written without mention of any specific type and thus, can be used transparently with any number of new types.

 
 

Multiple choice
  1. Protected proxy(InvocationHandler ih)

  2. Temporary intercession

  3. Public static object newProxyInstance(ClassLoader loader, class[] interfaces, InvocationHandler ih)

  4. Public object invoke(Object proxy, Method method, Object[] args)

  5. Proxy instance

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

This method creates a proxy class, defined in the specified loader and implements the specified interface.

Multiple choice
  1. Public static boolean inProxyClass(Class c)

  2. Protected proxy(InvocationHandler ih)

  3. Function proxy

  4. Public object invoke(Object proxy, Method method, Object[] arts)

  5. Proxy object

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

This method returns true if and only if the specified class was dynamically generated to a proxy class using the getProxyClass() method.

Multiple choice
  1. Proxy class

  2. Function proxy

  3. Abstract class

  4. Meta class

  5. The RemoteStackFrame class

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

This class implements all the interfaces specified at its creation and invoking getInterfaces() of its class object will return an array, containing the same list of interfaces.

Multiple choice
  1. harder

  2. simpler

  3. difficult

  4. none of these

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

Interfaces define the boundary and the set of operations available between adjacent layers. By standardizing the interface, the internal implementation of a layer can be changed or replaced without affecting the other layers, making system maintenance simpler.

Multiple choice
  1. hidden

  2. transparent

  3. visible

  4. none of these

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

In a layered architecture, the implementation details of a layer are hidden from the layers above it. The higher layer only interacts with the interface, which provides an abstraction of the services provided by the lower layer.

Multiple choice
  1. By defining virtual functions in class

  2. By defining pure virtual functions in class

  3. By defining virtual destructor

  4. By defining virtual constructor

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

 Abstract classes act as expressions of general concepts from which more specific classes can be derived. You cannot create an object of an abstract class type. However, you can use pointers and references for abstract class types.

A class that contains at least one pure virtual function is considered as an abstract class. Classes derived from the abstract class must implement the pure virtual function.