Let's look at these two classes:
class ClassC { public static String field = "static field C"; public static String m(String s){ return "static method C"; }}class ClassD extends ClassC { public static String field = "static field D"; public static String m(String s){ return "static method D"; }}
They have two static members each—a field and a method. With that, look at the following code:
System.out.println(ClassD.field);System.out.println(ClassD.m(""));System.out.println(new ClassD().field);System.out.println(new ClassD().m(""));ClassC object = new ClassD();System.out.println(object.field);System.out.println(object.m(""));
Stop reading and try to guess what will the output be.
Here is the same code with numbers of lines ...