What is the output of the given Java code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the output of the given Java code?

public class Test { public static void main(String[] args) { method(null); } public static void method(Object o) { System.out.println("Object method"); } public static void method(String s) { System.out.println("String method"); } }

23rd Nov 2021, 12:18 PM
Cāptaîn Råza Mhr
Cāptaîn Råza Mhr - avatar
1 Answer
+ 4
You can just run the code and see the output. It will be "String method".
23rd Nov 2021, 12:26 PM
Artem 🇺🇦
Artem 🇺🇦 - avatar