Skip to content
CodeKruPro

Calling an overloaded method with null

QuizMedium-HardJava only

Given these two methods, which statements are true? Pick all that apply.

static String over(Object o) { return "Object"; }
static String over(String s) { return "String"; }
  • over(null) returns "String"
  • over("text") returns "String"
  • Object o = "text"; over(o) returns "String"
  • over(null) does not compile because it is ambiguous

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in