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. (i),(iv),(vi).(viii)

  2. (i),(iv),(vii)

  3. (i),(iii),(v),(vi),(viii)

  4. (ii),(v),(viii)

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

Employee ID and employee name are independent of subclasses; manager engineer or secretary, so these should be implemented in super class, but salary is part of employee dependent, so abstract get salary should be in super class and its actual implementation in subclass.

Multiple choice
  1. 1 2 1

  2. 2 1 1

  3. 2 1 2

  4. 2 2 2

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

Multiple choice
  1.   class abc {
       Public static void main(String args[]) {……………}
      }
    
  2.   class abc {
       public Static void main(String args[]) {……………}
      }
    
  3.   class abc {
       Public static void Main(String args[]) {……………}
      }
    
  4.   class abc {
       public static void main(String args[]) {……………}
      }
    
Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The correct format for a Java program is as follows: class abc { public static void main(String args[]) { …………… } } Here, the keywords class, public and static must be in lower case. String is the class name.

Multiple choice
  1. Protected method does not access the public method.

  2. Method is accessible from inside a class and a subclasses.

  3. Protected method is not allowed within the Public class.

  4. Method is accessible from inside the class and all the classes defined in the same package, where the class is defined itself.

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

Protected method is accessible from inside the class and all the classes defined in the same package, where the class is defined itself.