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

    { } class B { } class C implements A,B { }|

  2. class A

    { } class B { } class C implement A,B { }|

  3. class A

    { } class B { } class C extends A,B { }|

  4. class A

    { } class B { } class C extend A,B { }|

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

The implementation in Java for the given structure is as follows: class A { } class B { } class C implements A,B { }

Multiple choice
  1. A class can extend another class.

  2. A class can implement multiple interfaces.

  3. A class can extend multiple classes.

  4. An interface can extend another interface.

  5. A class can extend another class and implement an interface at the same time.

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

This is a false statement. Multiple inheritence is not supported in Java.

Multiple choice
  1. A constructor can be executed simultaneously with the creation of an object.

  2. A constructor which is used for one object cannot be used again unless a second object is created.

  3. A constructor does not return a value.

  4. A constructor cannot be overloaded.

  5. A constructor must have the same name as its class.

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

Since the statement is true about constructors, it the wrong answer. Since the statement is not true about constructors, it  is the correct answer.

Multiple choice
  1. class person()

  2. talk()

  3. person()

  4. private int age;

  5. none of these

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

This is a constructor since the class is also person and the constructors have the same names as that of their classes. It is wrongly defined in the program as void is used before constructor which is not allowed.

Multiple choice
  1. Static methods can be accessed using the class name.

  2. Static methods can be accessed directly by writing the method name.

  3. Static methods can be accessed using objects of the class, where the static method is defined.

  4. Static methods can be accessed using “this”.

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

Static methods can be accessed using the class name. Syntax: Classname.Static_method();