Multiple choice technology programming languages

What is the output for the below code ? public class B { public String getCountryName(){ return "USA"; } public StringBuffer getCountryName(){ StringBuffer sb = new StringBuffer(); sb.append("UK"); return sb; } public static void main(String[] args){ B b = new B(); System.out.println(b.getCountryName().toString()); } }

  1. Compile with error

  2. USA

  3. UK

  4. Runtime Exception

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Java uses method signature (name + parameter types) to distinguish methods. Return type alone cannot differentiate overloaded methods. Two getCountryName() methods with identical parameter lists (both empty) are ambiguous, causing a compilation error regardless of return types.