I came across following code :
public class TradingSystem {
private static String category = "electronic trading system";
public static void main(String[] args) {
TradingSystem system = null;
System.out.println(system.category);
}
Output : electronic trading system
I was surprised to not find a NullPointerException !
Q1. Why didn't it throw the NullPointerException
?
Q2. Or while compile time, due to category's declaration having static
made it to replace the system(i.e object reference) with TradingSystem
and as such essentially TradingSystem.category
was called?