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. member function

  2. manipulator

  3. allocator

  4. operator

  5. constructor

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

Allocators are important components of the C++ Standard Library. The standard library provides several data structures, such as list and set, commonly referred to as containers.

Multiple choice
  1. java.lang.Class

  2. java.util.Name

  3. java.lang.Object

  4. java.awt.Window

  5. java.dll.obj

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

The java.lang.Object class is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.

Multiple choice
  1. Nested classes

  2. Anonymous classes

  3. Sub classes

  4. Derived classes

  5. Lower classes

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

The Java programming language allows one to define a class within another class. Such an inner class is called a nested class.

Multiple choice
  1. Indexer modifier can not be private.

  2. Indexer can have static and instance members.

  3. Properties can have instance and static members.

  4. A get accessor of an indexer has no parameter.

  5. All of the above.

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

This is true about properties.

Multiple choice
  1. It will print (2,4) and (0,0) as output.

  2. It will print (2,0) and (0,4) as output.

  3. It will not compile because we can not create the object of structure without using new keyword.

  4. It will not compile because we can not instantiate a structure.

  5. None of the above

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

This output will be produced. Struct A is instantiated two times and the objects a and b will define the values accordingly.

Multiple choice
  1. A structure is a value type.

  2. A structure may contain constructor.

  3. A structure can not be inherited.

  4. A structure can not implement a interface.

  5. None of the above

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

This is a false statement as a struct can implement the interfaces.