Java Method Overloading

Java Method Overloading

University

6 Qs

quiz-placeholder

Similar activities

pointers and structures

pointers and structures

University

10 Qs

Teste python- Unesp-Jaboticabal

Teste python- Unesp-Jaboticabal

University

10 Qs

Chapter 5-1: Review Questions & Exercises

Chapter 5-1: Review Questions & Exercises

University

10 Qs

ICF-Mechanical-(Theory Quiz-2)

ICF-Mechanical-(Theory Quiz-2)

University

10 Qs

Python quick quiz

Python quick quiz

University

10 Qs

HTML Quiz

HTML Quiz

University

10 Qs

Algoritmos y Estrutura de datos S2

Algoritmos y Estrutura de datos S2

University

10 Qs

PSP Week 5

PSP Week 5

University

10 Qs

Java Method Overloading

Java Method Overloading

Assessment

Quiz

Computers

University

Practice Problem

Hard

Created by

Jamunadevi T

Used 8+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

6 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following program?

class A

{

 

}

 

class B extends A

{

 

}

 

class C extends B

{

 

}

 

public class MainClass

{

    static void overloadedMethod(A a)

    {

        System.out.println("ONE");

    }

 

    static void overloadedMethod(B b)

    {

        System.out.println("TWO");

    }

 

    static void overloadedMethod(Object obj)

    {

        System.out.println("THREE");

    }

 

    public static void main(String[] args)

    {

        C c = new C();

 

        overloadedMethod(c);

    }

}

1

2

3

4

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In a class, one method has two overloaded forms. One form is defined as static and another form is defined as non-static. Is that method properly overloaded?

Yes

No

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In the below Class X, is ‘method’ properly overloaded?

class X

{

    int method(int i, int d)

    {

        return i+d;

    }

 

    static int method(int i, double d)

    {

        return (int)(i+d);

    }

 

    double method(double i, int d)

    {

        return i+d;

    }

 

    static double method(double i, double d)

    {

        return i+d;

    }

}

Yes

No

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following program?

class X

{

    void method(int a)

    {

        System.out.println("ONE");

    }

 

    void method(double d)

    {

        System.out.println("TWO");

    }

}

 

class Y extends X

{

    @Override

    void method(double d)

    {

        System.out.println("THREE");

    }

}

 

public class MainClass

{

    public static void main(String[] args)

    {

        new Y().method(100);

    }

}

1

2

3

4

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Method Overriding shows static polymorphism. True or false?

True

False

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In a class, One method has 4 overloaded forms. All have different access modifiers (private, default, protected and public). Is that method properly overloaded?

Yes

No

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers