public class B {
// Method to be overloaded
public String greet() {
return "Hello";
}
//This will work
public StringBuilder greet(String name) {
return new StringBuilder("Hello " + name);
}
//This will not work
//Error: Duplicate method greet() in type B
public StringBuilder greet() {
return new StringBuilder("Hello Tarzan");
}
}