Guys,I apologize forehead if i ask silly questions.
I have two classes, class Pet and PetMaster. I have a few quiestions what means what, please look at comments :
as a result, i get :
I’m so hungry…let me have a snack like nachos!
OK!! OK!! Tweet!! Tweet!!
Good night, see you tomorrow
Question 1: in the main class i didnt called aWord (i did myPet.say),why then i get such a result? (OK!! OK!! Tweet!! Tweet!!). could you please explain how petReaction connected with method "say" from class Pet?
Question 2: i think the output is what follows System.oupt.println. why do i get output from the myPet.eat();
aWord in that method is what is called a formal parameter. When the method is called, you send a corresponding actual parameter, whose value gets copied into aWord. aWord can then be used in the method.
The reason you get output when you call myPet.eat() is that method contains a System.out.println statement.
posted 5 years ago
Brilliant! I got it!Thank you very much!
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.