MCQ – Java oops concept

Q) Java object oriented programming concepts is/are
  1. Encapsulation
  2. Inheritance
  3. polymorphism
  4. All of the above.

Answer: 4

Q) Java does not support _______________?
  1. Inheritance
  2. Multiple inheritance for classes
  3. multiple inheritance of interfaces
  4. compile time polymorphism

Answer: 2
Java does not support multiple inheritance for classes but in java multiple inheritance behavior is implemented using interfaces.

Q) Runtime polymorphism feature in java is
  1. method overriding
  2. method overloading
  3. constructor overloading
  4. operator overloading

Answer: 1
Since in method overriding both the classes(base class and child class) have same method, compile doesn’t figure out which method to call at compile-time. In this case JVM(java virtual machine) decides which method to call at runtime that’s why it is known as runtime or dynamic polymorphism.

Q) Encapsulation concept in java is
  1. Hiding complexity
  2. method hiding
  3. Hiding constructor
  4. None

Answer: 1

Q) Following concept can be used for encapsulation in java programs
  1. Wrapping data fields with methods
  2. Hiding data and internal methods using access modifiers in a class
  3. Using Interfaces
  4. All of the above

Answer: 4
Encapsulation means, hiding the complexities in java programs. All options above are used to implement encapsulation in java object oriented programming.

Related Posts