Forums Register Login

need a hand to understand the code

+Pie Number of slices to send: Send
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();

Thank you!
Dana
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Brilliant! I got it!Thank you very much!
Not looking good. I think this might be the end. Wait! Is that a tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 634 times.
Similar Threads
Help getting back on track with assignment
I keep getting null
Rate my code
construct 2 dimensional array
Question on Bitwise Conditional Operator
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:45:34.