Let us assume the number of Hens are H and Number of Goats are G.
According to question,
The total number of animal heads are 81. Since one animal has one head.
Number of head of animals = Number of total animals
H + G = 81..........................(1)
The total number of animal legs are 234. Since hen's have 2 legs and goat's have 4 legs.
2H + 4G = 234...................(2)
Multiply 2 with equation (1) and subtract from equation (2), we will get.
⇒ 2H + 4G - 2 x (H + G ) = 234 - 2 x 81
⇒ 2H + 4G - 2H - 2G = 234 - 162
⇒ 2G = 72
⇒ G = 36
Put the value of G in equation (1), we will get.
H + 36 = 81
H = 81 - 36
H = 45
Krishna have number of goats = G = 36