anonymous
  • anonymous
Assume that FarmAnimal contains this method: public String mySound() { return “moo”; } Write a method in the Cow class that overrides this method (same name and return type and parameters). The method in the Cow class must call the mySound method in FarmAnimal twice so that the end result is that the Cow’s method returns moomoo. Do not do this: return “moomoo”;
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
public class Cow{ String mySound(){ return farmAnimal.mySound(); } } ?????
KonradZuse
  • KonradZuse
Okay so you have a class FarmAnimal and need to get one of it's methods. public class cow extends FarmAnimal. By extending FarmAnimal you get all of it's goodies(Methods, Properties, variables, functions, etc), that are allotted for use. For example if it's a protected method you cannot access it externally. next we need to override the method String mySound() @Override public String mySound() { //return } The problem is.... They don't want us to do "return moomoo" we need to call it twice, which is interesting.... Imo from here we can do a few things. I think we will do it this way. @Override public String mySound() { String s; s = super.mySound(); s += super.mySound(); return s; } The only issue I see is that since we are "Overriding" mySound, will it affect the super call? I personally don't think so because we are just overriding the data from super.mySound in our cow class, which the FarmAnimal should be left alone.. I am not 100% sure though. This is a really good example!
anonymous
  • anonymous
i acutally think im gonna do : return super.mySound()+super.mySound();

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

KonradZuse
  • KonradZuse
yeah, see what happens.
anonymous
  • anonymous
i think u got to specify that mysound is the baseclass of cow and then it says u got to return the name o.o

Looking for something else?

Not the answer you are looking for? Search for more explanations.