The first sample program object argument is overloaded by String object. So when you pass null as a parameter it calls String object method.
In sample2 It has Stringbuffer parameter and String object parameter. The null parameter has matched with two methods. So it confused. That's a reason it gives "method is ambiguous" error.