0 votes
in JAVA by
What is the output of below program?

package com.journaldev.strings;

public class Test {

public void foo(String s) {

System.out.println("String");

}

public void foo(StringBuffer sb){

System.out.println("StringBuffer");

}

public static void main(String[] args) {

new Test().foo(null);

}

}

1 Answer

0 votes
by

The above program will not compile with error as “The method foo(String) is ambiguous for the type Test”. For complete clarification read Understanding the method X is ambiguous for the type Y error.

Related questions

0 votes
asked Mar 16, 2021 in JAVA by Robindeniel
0 votes
asked Feb 8, 2020 in JAVA by rahuljain1
...