in the above code in equals method parameter why Object type parameter is used first and then later typecasted into Moof type in the if statement,
in place of "Object o" we could have directly given "Moof o" ??
What you're doing is overriding the equals() method from Object, and that's declared with an Object argument. So in order to override it you need to have the same signature. The equals method should be callable with any parameter.
You could define an equals(Moof) method. But that wouldn't be an override, and whike your test there might work, other code might not.