Why is the output 9 not 6 ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is the output 9 not 6 ?

What is the output of this code? static void Print(int a) { Console.WriteLine(a*a); } static void Print(double a) { Console.WriteLine(a+a); } static void Main(string[] args) { Print(3); }

12th Nov 2019, 11:10 AM
Xun
Xun - avatar
3 Answers
+ 1
Yep because 3 is an integer This is a case of overloading. https://www.sololearn.com/learn/Java/2165/?ref=app
12th Nov 2019, 11:32 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
Is it because Print(3) is an integer ?
12th Nov 2019, 11:13 AM
Xun
Xun - avatar
0
Thanks a bunch!
12th Nov 2019, 1:24 PM
Xun
Xun - avatar