Why doesn't a Java static method call on a null object generate a NullPointerException?

What is an exception?

An exception is an error that occurs at runtime which disrupts the normal flow of the application.  It is either generated by the Java Virtual Machine (JVM) in response to an unexpected condition or by your code as a result of executing a throw statement.

Unchecked exceptions

Exceptions generated at run-time are called unchecked exceptions, since it is not possible for the compiler to determine that your code will handle the exception.  The exception classes that descend from RuntimeException and Error classes are unchecked exceptions.   

Checked exceptions

Thrown exceptions are referred to as checked exceptions.  The compiler will confirm at compile time that the method includes code that might throw an exception. Moreover the compiler requires the code that calls such a method to include this call within a try block, and provide an appropriate catch block to catch the exception.

What is a NullPointerException?

One of the most common unchecked exceptions is the NullPointerException.  It is thrown whenever an application attempts to use an object reference that has a null value.  

Object o = null;
String s = o.toString();

What happens with static methods?

If we call a static method on an object with a null reference, we won't get an exception and the code will run.

public class Player {
  private static final String type = "Human";
  private int age;
  public static String getType() {
    return type;
  public int getAge() {
    return age;
  public static void main(String[] args) {
    Player player = null;
    System.out.println(player.getType()); // Human
    System.out.println(player.getAge());  // throws NullPointerException
Static members belongs to the class rather than instance.   So at compile time, player.getType() is converted to Player.getType()

\This is admittedly very misleading when reading someone else's code, and it is best practice to always use the class name when calling a static method.