
Quiz on Method Overloading

Quiz
•
Computers
•
11th Grade
•
Hard
Sugeng Riyanto
FREE Resource
14 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is method overloading?
Creating multiple methods with the same name but different parameters
Creating methods that only accept one type of parameter
Creating methods with different names
Creating methods that cannot be reused
Answer explanation
Method overloading allows the creation of multiple methods with the same name but different parameters, enabling flexibility in method usage based on the input types or number of arguments.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How many types of parameters can be used in method overloading?
No parameters
Different types or different numbers
Two types
Only one type
Answer explanation
Method overloading allows methods to have the same name but different parameters. This can be achieved by using different types of parameters or varying the number of parameters, making 'Different types or different numbers' the correct choice.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In the example, what is the first parameter type of the Details method?
double
int
char
String
Answer explanation
The first parameter type of the Details method is String, as indicated in the example. This means it expects a sequence of characters as input, making String the correct choice.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be printed when Details("Ridhi", 89) is called?
Welcome Ritesh Your got 89 marks in exam.
Welcome Ridhi Your got 89 marks in exam.
Welcome Ridhi Your got 0 marks in exam.
Welcome Ridhi Your got 93.5 marks in exam.
Answer explanation
The function call Details("Ridhi", 89) correctly uses the name 'Ridhi' and the score 89, resulting in the output: 'Welcome Ridhi Your got 89 marks in exam.' This matches the second answer choice.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the second parameter type in the second Details method?
float
double
int
String
Answer explanation
The second Details method has a second parameter of type double, which is used for representing decimal values with higher precision than float. This makes double the correct choice among the options provided.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the static keyword indicate in the Details method?
The method is private
The method cannot be called
The method belongs to the class, not instances
The method can be overridden
Answer explanation
The static keyword indicates that the method belongs to the class itself rather than to any specific instance of the class. This means it can be called without creating an instance, making it accessible at the class level.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will happen if you call Details("Ritesh", 93) instead of Details("Ritesh", 93.5)?
It will call the second Details method
It will throw an error
It will compile successfully
It will call the first Details method
Answer explanation
Calling Details("Ritesh", 93) will throw an error because it does not match any overloaded method signature. The method expects a double (93.5) instead of an integer (93), leading to a type mismatch.
Create a free account and access millions of resources
Similar Resources on Wayground
18 questions
Object Orientated Programming (BTEC Computing)

Quiz
•
11th - 12th Grade
10 questions
Dictionary in Python

Quiz
•
11th - 12th Grade
18 questions
8.3 Phishing, Pharming, Smishing

Quiz
•
11th Grade
10 questions
OOP 4 Polymorphism

Quiz
•
11th Grade
12 questions
OOP Pengenalan

Quiz
•
11th Grade
15 questions
Fanuc Labs 1-6

Quiz
•
10th - 12th Grade
15 questions
Java Inheritance Quiz

Quiz
•
11th Grade
10 questions
Pewarisan Antar Interface

Quiz
•
11th Grade
Popular Resources on Wayground
55 questions
CHS Student Handbook 25-26

Quiz
•
9th Grade
10 questions
Afterschool Activities & Sports

Quiz
•
6th - 8th Grade
15 questions
PRIDE

Quiz
•
6th - 8th Grade
15 questions
Cool Tool:Chromebook

Quiz
•
6th - 8th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
20 questions
Bullying

Quiz
•
7th Grade
18 questions
7SS - 30a - Budgeting

Quiz
•
6th - 8th Grade