The String class has nothing to do with it.
The variable holds a
reference to an object. If the reference is null and you try to call a method using it, you get a NullPointerException. That is true always, regardless of the class of object to which the variable is declared to refer.
Unlike other languages (e.g. C++),
Java cannot have variables that hold an object. They always hold a reference to an object, or they hold a primitive like an "int".