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. Class A is derived in class B

  2. Method of class A is implemented in class B

  3. Class B is derived in class A

  4. Class A and class B are same class

  5. Class B cannot be derived in class A

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

This is the correct option as colon operator is used in C# to inherit any class in an existing class.

Multiple choice
  1. Declare the method outside the base class only.

  2. Declare the method in the derived class only.

  3. Declare the method in both base class and derived class.

  4. Declare the method in the base class with the keyword 'Hide'.

  5. Delete the method declared in base and derived class.

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

This is the correct option as the method is declared in both base and derived class by default the derived version of the method is only accessible but to access the base class method the following changes has to be done in the program. DerivedClass test = new DerivedClass();  ((BaseClass)test).TestMethod();   The above code will only access the base class method of a class.