Quiz

Let's test your understanding of the concept of polymorphism with the help of a short quiz.

1

What is the output of the following piece of code?


class Base {
  
  public Base() {}
  public void print() { 
    System.out.println("Base");
  }
}

class Derived extends Base {

  public Derived() {}
  public void print() {
    System.out.println("Derived");
  }
}

class Demo {
  
  public static void main(String args[]) {
    Base obj = new Derived();
    obj.print();
  }
}

A)

Base

B)

Base
Derived

C)

Derived

D)

None of the above

Question 1 of 50 attempted

Get hands-on with 1000+ tech skills courses.