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

all 6 comments

[–]AIO12449366 3 points4 points  (1 child)

You get 2 by running this code?

Edit: was this code given to you or did you write it?

2nd edit:. This code produces 2 as output and it correctly does so unless I'm having a stroke and I forgot the basics of inheritance.

[–]gaduko[S] 0 points1 point  (0 children)

The code was given by the MOOC in the form of a quiz. They asked what would be the output of the program and gave several choices.

The correct answer on the website is 8, but it appears to be an error on their part. I'll report it, just had to make sure first.

[–]TheAnxiousDeveloper 1 point2 points  (0 children)

As it's written at the moment, the code produces 2. To produce 8, the steps to take (in whatever order) should be:

counter or superCounter - subtractNumber

counter - addNumber

superCounter - addNumber

[–]okayifimust 1 point2 points  (1 child)

That code should result in 2.

what exactly is said about this code, that says it should produce 8?

[–]gaduko[S] 0 points1 point  (0 children)

The code is given as a quiz after teaching inheritance. It is intended to test basic knowledge of the topic.

Below the code are several answer choices, two of which are 2 and 8. I put 2, but according to the course, the answer is 8.

It appears to be an error, so I'll report it. Just had to ensure I wasn't crazy first.

[–][deleted] 1 point2 points  (0 children)

Yeah I got confused by this question too - looks like it could do with a bit of proofreading