Site icon DataFlair

Quiz on Polymorphism in Java

quiz on polymorphism in java

Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java

Polymorphism, a cornerstone of object-oriented programming (OOP), is a powerful tool that injects flexibility and dynamism into your code. Imagine being able to write concise, reusable, and maintainable code that adapts its behavior based on the objects it interacts with. That’s the magic of polymorphism!

This in-depth Java quiz dives headfirst into the world of polymorphism, putting your understanding to the test. It will explore various aspects of polymorphism in Java, from grasping the core concepts of method overriding and overloading to applying these techniques effectively in your programs.

By tackling these challenges, you’ll not only solidify your grasp of polymorphism but also unlock its potential to write cleaner, more versatile, and future-proof Java code. Prepare to be challenged and expand your knowledge of this essential OOP concept!

Time limit: 0

Quiz Summary

0 of 15 Questions completed

Questions:

Information

You have already completed the quiz before. Hence you can not start it again.

Quiz is loading…

You must sign in or sign up to start the quiz.

You must first complete the following:

Results

Quiz complete. Results are being recorded.

Results

0 of 15 Questions answered correctly

Your time:

Time has elapsed

You have reached 0 of 0 point(s), (0)

Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)

Categories

  1. Not categorized 0%
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  1. Current
  2. Review / Skip
  3. Answered
  4. Correct
  5. Incorrect
  1. Question 1 of 15
    1. Question

    If a class is overridden with a reference variable of a parent class then which datamember will  be passed as an argument ?

    Correct
    Incorrect
  2. Question 2 of 15
    2. Question

    class Programming {

    void Print ( ) {

    System.out.println(“There are many programming languages”);

    }

    };

    class Java extends Programming {

    void Print ( ) {

    System.out.println(“ Java is a programming language”);

    }

    };

    class Main {

    public static void main ( String args [ ] ) 

    {

    Programming p = new Java();

    p.Print();

    }

    }

    Correct
    Incorrect
  3. Question 3 of 15
    3. Question

    class One {

    void method();{ 

    System.out.println(“Method of class A”);

    }

    };

    class Two extends One {

    void method(); { 

    System.out.println(“Method of class B”);

    }

    void method2(); {

    (System.out.println(“Method of class B”);

    }

    };

    class Main {

    public static void main ( String args [ ] )

    {

    One object = new Two();

    object,method();

    }

    }

    Correct
    Incorrect
  4. Question 4 of 15
    4. Question

    Which concept in Java is used to perform Polymorphism ?

    Correct
    Incorrect
  5. Question 5 of 15
    5. Question

    class First {

    String a = “DataFlair”;

    };

    class Second extends First {

    String a = “Webservices”;

    void Display() {

    System.out.println(a);

    }

    };

    Class Main {

    public static void main ( String args [ ] )

    {

    First obj = new Second();

    obj.Display();

    }

    }

    Correct
    Incorrect
  6. Question 6 of 15
    6. Question

    class Polymorphism {

    void Method ( ) {

    System.out.println(“This method can be executed “);

    }

    };

    class B extends Polymorphism {

    final void Method ( ) {

    System.out.println(“This method cannot be executed”);

    }

    };

    class Main {

    public static void main ( String args [ ] )

    {

    Polymorphism p = new B();

    B.method();

    }

    }

    Correct
    Incorrect
  7. Question 7 of 15
    7. Question

     class Main {

    public static void main ( String args [ ] )

    {

    void Print( ) {

    System.out.println(“DataFlair”);

    }

    void Print( Char a) {

    System.out.println(a);

    }

    Main m = new Main();

    m.Print();

    m.Print(“DataFlair”);

    }

    }

    Correct
    Incorrect
  8. Question 8 of 15
    8. Question

    class Program {

    public static void main ( String args [ ] )

    {

    Void add ( int a , int b)

    {

    System.out.println(a + b );

    }

    void add(char a , char b)

    {

    System.out.println( a + b );

    }

    Program p = new Program();

    p.add(1,2);

    p.add(“Data”,”Flair”);

    }

    }

    Correct
    Incorrect
  9. Question 9 of 15
    9. Question

    Method overriding is present in class A and B. Other than it another method is also present in 

       class B. In these methods which cannot be accessed by reference variables of class A ?

    Correct
    Incorrect
  10. Question 10 of 15
    10. Question

    Constructor overloading is which type of polymorphism concept ?

     

    Correct
    Incorrect
  11. Question 11 of 15
    11. Question

    class Frameworks {

    void Display(“ Frameworks “);

    }

    };

    class AppDevelopment extends Frameworks {

    void Display(“ Android studio , Flutter “);

    }

    };

    class WebDevelopment extends Frameworks {

    void Display ( “ HTML , CSS “);

    }

    };

    class Main {

    public static void main ( String args [ ] )

    {

    Frameworks f = new Frameworks();

    Frameworks f1 = new AppDevelopment();

    Frameworks f2 = new WebDevelopment();

    f1.Display(“Flutter”);

    }

    }

    Correct
    Incorrect
  12. Question 12 of 15
    12. Question

    class Polymorphism {

    void Method1 {

    System.out.println(“Private Limited”);

    }

    };

    class Concept extends Polymorphism {

    void Method2 {

    System.out.println(“Webservices”);

    }

    void Method3 {

    System.out.println(“DataFlair”);

    }

    };

    class Main {

    public static void main ( String args [ ] ) {

    }

    }

    Correct
    Incorrect
  13. Question 13 of 15
    13. Question

    What is the concept of referring object of child class with the reference variable of parent 

          class ?

    Correct
    Incorrect
  14. Question 14 of 15
    14. Question

     class Sample {

    void Method() {

    System.out.println(“Super class Method”);

    }

    };

    class Example extends Sample {

    void Method() {

    System.out.println(“SubClass Method”);

    }

    public static void main ( String args [ ] )

    {

    Sample s = new Example();

    s.Method();

    }

    }

    Correct
    Incorrect
  15. Question 15 of 15
    15. Question

    class Organisms {

    void foursesnse ( String a , string b , string c , string d )

    {

    System.out.println(“Bats have four senses”);

    }

        void fivesense ( string a , string b , string c , string d , string e )

    {

    System.out.println(“Elephant has five senses”);

    }

    void sixsenses ( String a , String b , String c , String d , String e , String f )

    {

    System.out.println(“Humans has six senses”);

    public static void main ( String args [ ] )

    {

    Organisms obj = new Organisms();

    obj.(“Vision” , “touch” , “smell” , “hearing “ , “taste”);

    }

    }

    Correct
    Incorrect

Summary:

Ready to test your understanding of polymorphism in Java? This comprehensive quiz delves into the heart of this powerful concept, covering key aspects like method overriding, runtime polymorphism, and wielding the flexibility of reference variables from parent classes.

By tackling these questions, you’ll embark on a journey of self-discovery, pinpointing areas where you confidently navigate polymorphism’s intricacies and uncovering topics that might benefit from further exploration. Remember, polymorphism stands as a cornerstone of the Java developer’s toolkit.

Mastering its nuances will significantly elevate your coding prowess, allowing you to craft elegant and versatile programs. So, don’t hesitate – dive right in, challenge yourself with the quiz, and unlock the full potential of polymorphism in your Java development endeavors!

Exit mobile version