The following code in java, when run on elipse, gives same output even if we replace
superclass s=new sub();
with,
sub s= n
you are creating Object of sub and assigning it to super's reference.if you dont 1)first case:-
superclass s=new sub();
s.supermethod();
s.method();
in above case methods of sub will be called but these two method should be present in superclass also(if not present then compile time error)
2)second case:-
sub s=new sub();
s.supermethod();
s.method();
in this also methods of sub will be ,these method may or may not be present super.