A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/quizzes/java-polymorphism-and-packages/ below:

Quiz about Java Polymorphism and Packages

What is the key difference between compile-time and runtime polymorphism in Java?

What will be the output of the following code?

Java
class A {
    void display() {
        System.out.println("Class A");
    }
}
class B extends A {
    void display() {
        System.out.println("Class B");
    }
}
public class Main {
    public static void main(String[] args) {
        A obj = new B();
        obj.display();
    }
}

Which of the following statements about method overloading is true?

What will be the output of this code?

Java
class Parent {
    static void show() {
        System.out.println("Parent");
    }
}
class Child extends Parent {
    static void show() {
        System.out.println("Child");
    }
}
public class Main {
    public static void main(String[] args) {
        Parent p = new Child();
        p.show();
    }
}

What is the primary use of packages in Java?

What will happen if two classes in different packages have the same name and are imported in a Java file?

Which access modifier allows a member to be accessible within the same package but not from outside?

What will be the output of the following program?

Java
package pack1;
public class A {
    public void display() {
        System.out.println("Hello from A");
    }
}

package pack2;
import pack1.A;
public class B {
    public static void main(String args[]) {
        A obj = new A();
        obj.display();
    }
}

Which of the following correctly defines method overriding?

Which of the following best demonstrates runtime polymorphism in Java?

There are 10 questions to complete.

Take a part in the ongoing discussion


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4