You are misleading two things :-
1) Line 23 : - In line 23 your are trying to print n which is referring to an Object ie int[] and hence shows hascode value.
2) Line 35 :- You are trying to print a , which is first referring to dog and then to cat. Remember System.out.println() uses toString() method while printing its argument object. So when it tries to print Dog object , it would print its Inherited method from Object class, which says to print the hashcode value. Similar is the case with code.
If you want to print something then you must override toString() method in dog and cat class, which would be used during printing.
Thanks !!!
Hope you got my point !!!
Happy Learning !!!
Best Wishes !!!