Tim Havinga

Greenhorn
+ Follow
since Jun 04, 2020
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tim Havinga

Thank you for your responses. I understand that creating a compiler is hard (and have not tried it myself).

The possible answers in the book (mentioned in the thread title) are:
A) It compiles without issue
B) The code will not compile because of line 5.
C) The code will not compile because of line 6.
D) The code will not compile because of line 7.
E) The code will not compile because of line 9.
F) The code will not compile because of line 10.
G) The code will not compile because of line 13.

The book states that answers C and G are correct because of the missing semicolon and the conflicting interfaces.

That had me wondering: if a line with a method declaration (line 6) fails to compile, is it then taken into account for the rest of the compilation or is it left out? In the latter case, line 13 would not issue a compiler error.

The code in my first post is identical to the question (I replaced "distance" with "dist", but that does not make a difference).
A question about review question 10 of chapter 9 of the book, containing the following code:



When I enter the code in the question and try to compile it, I get the following error messages:



While the answer states that line 13 is incorrect. Indeed, when I insert the semicolon at line 6, the error is:



So the correct answers would be C and D. But that is crazy. Do you know how the compiler handles these situations? I would assume that it would go forward as if the semicolon was inserted at line 6 and give the last error.