nus-cs2103-AY2021S1 / forum

20 stars 2 forks source link

Seeking Clarification for Practice exam - part 2 answers #500

Closed xinyee20 closed 3 years ago

xinyee20 commented 3 years ago

image 1) How does one derive that the level of access is package private from the information given in the question? (I can't seem to infer it from any part of the question) image 2) Should ProgressWatcher have an update(int) method too since it implements the interface Watcher?

ong-yinggao98 commented 3 years ago
1. How does one derive that the level of access is package private from the information given in the question? (I can't seem to infer it from any part of the question)

Activity#getInstance() and ProgressWatcher.MAX has no public/private/protected prefixes, which in Java means it is default visibility (i.e. package-private).

2. Should ProgressWatcher have an update(int) method too since it implements the interface Watcher?

I think it's not compulsory? Because an abstract class implementing the interface without implementing update(int) can already be inferred to have it as an abstract method.

damithc commented 3 years ago

@StopTakingAllTheNames 's answer is correct.

Plus, the ProgressWatcher code is given, and it confirms that it doesn't have that method.

xinyee20 commented 3 years ago

Ahh I see, thankyou:) @StopTakingAllTheNames @damithc