I have great difficulty in understanding the operation of the code supplied with the exercises mentioned.
#12
Given this code:
Which letters will eventually appear somewhere in the output?
Correct answers:
A. A
C. C
D. D
E. E
F. F
#13
Given this code:
and given the following five fragments:
I. new Starter().run();
II. new Starter().start();
III. new Thread(new Starter());
IV. new Thread(new Starter()).run();
V. new Thread(new Starter()).start();
When the five fragments are inserted, one at a time at line 9, which are true?
Correct answers:
C. Only one might produce the output 4 2
D. Exactly two might produce the output 4 4
#15
Given this code:
And given these two fragments:
I. synchronized void chat(long id) {
II. void chat(long id) {
When fragment I or fragment II is inserted at line 5, which are true?
Correct answer:
F. With fragment II, the output could be yo dude dude yo
#16
Given this code:
Which are true?
Correct answer:
F. An exception is thrown at runtime
#17
Given this code:
And given these two fragments:
I. synchronized void move(long id) {
II. void move(long id) {
When either fragment I or fragment II is inserted at line 7, which are true?
Correct answers:
C. With fragment I, the output could be 4 2 4 2
E. With fragment II, the output could be 2 4 2 4
I just can not understand why the correct answers are those. Can you help me understand?
I apologize for the amount but I just can not understand.