Java Method Overloading

Quiz
•
Computers
•
University
•
Hard
Jamunadevi T
Used 8+ times
FREE Resource
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
Similar Resources on Wayground
10 questions
Java variables

Quiz
•
University
10 questions
Java

Quiz
•
University
5 questions
Programming in Java - Output Prediction

Quiz
•
University
10 questions
Weekly Contest #3 - TechXNinjas

Quiz
•
University
10 questions
C#.net test 1

Quiz
•
University
10 questions
Java Inheritance

Quiz
•
11th Grade - University
9 questions
c language quiz

Quiz
•
University
8 questions
Java operators

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University