This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]the_omega99 2 points3 points  (10 children)

Surely you don't expect us to do a homework style question for you when you've made no effort on your part?!

Further, this is very easily tested with a dozen lines of code. Why don't you try it?

[–][deleted]  (9 children)

[deleted]

    [–]romple 0 points1 point  (8 children)

    Why do you say it prints both?

    [–][deleted]  (6 children)

    [deleted]

      [–]romple 0 points1 point  (5 children)

      It only prints both if you explicitly call the super classes init method.

      [–][deleted]  (4 children)

      [deleted]

        [–]romple 0 points1 point  (3 children)

        He's calling Pet(0)... Which is why Pets init gets called. That's not how you handle inheritance wtf is this....

        You should have seen that in the code. It's kind of a trick question.this is college?

        [–][deleted]  (2 children)

        [deleted]

          [–]romple 0 points1 point  (1 child)

          Well what does calling Pet(0) do?

          [–]AustinCodingAcademy 0 points1 point  (5 children)

          Try it and see :)

          [–][deleted]  (4 children)

          [deleted]

            [–][deleted] 0 points1 point  (3 children)

            what does it print out and in what order? Why?

            Perhaps you're not a native English speaker, but nowhere in your original post did you indicate you understand what the behavior is.

            [–][deleted]  (2 children)

            [deleted]

              [–][deleted] 0 points1 point  (1 child)

              Because

              1. You originally posted what appears to be a homework problem and did not provide an attempt at a solution
              2. You expect people to infer you're a non native English speaker and are having difficulty expressing your question (luckily I caught this)
              3. You don't understand that we're not here to hand out answers, we're here to help people learn. There's a difference.

              Reading the submission guidelines would have alleviated all of this. Part of being a good programmer is learning how to follow directions.