Sachin,
Remeber that when a call is made on overloaded methods, the most specific method will be called.
Now, remember that the
String extends Object. Which means the String is more
specific than the Object. So, the compiler calls the String version, in your second example. But in your first example, there is no inheritence relationship between String and StringBuffer. Hence the compiler is not sure, which one is more specific. Hence the error.