Um, okay, I think I got it. Please correct me if I'm wrong. No exceptions are thrown because nothing really happens to the object that was passed to append(). It just got casted to a string. If we were to call some methods like length(), then we would've gotten an exception. So NullPointerException is thrown only if we try to use members of the class.
Have you looked at the documentation for the append() method? It says exactly what should happen here. Not all methods throw NullPointerException if you pass them a null.
Note that this is more detail than you need for SCJP. The exact behavior of a specific method like append() isn't that important. Now if s1 had been null, then that would throw a NullPointerException, and that's a general enough rule that are expected to know something like that for SCJP.
Certainly if you try to dereference a null reference, you will get an exception.
But in situations like this, it's often informative to check the API. For StringBuffer's append(Object) method, it states, "The argument is converted to a string as if by the method String.valueOf..." So the question becomes: How does String.valueOf handle a null value? And writing a bit of code around what you have will answer this.
(Note that nothing is "cast" to type String here.)
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Police line, do not cross. Well, this tiny ad can go through:
ScroogeXHTML - a fast and small RTF to HTML5 and XHTML converter library