How are ferrets and hamsters alike and different?

They're as different as humans and elephants - in fact, like humans and elephants, the only thing they really have in common is they're both mammals.

Aside from the difference in size, other differences include-

Ferrets are Mustelidae (weasel family), hamsters are Rodentia (rats, mice etc.)

Ferrets are obligate carnivores and can eat only meat, hamsters are omnivores (they eat mostly seeds, nuts and plant matter - which would make a ferret ill, possibly even killing it - but can also eat insects).