About Question enthuware.ocpjp.v21.2.4000 :
Posted: Tue Mar 04, 2025 6:56 pm
One of the correct answers suggests that the call to "Thread.sleep(10000)" can be replaced with "while(!isInterrupted()) {}". However, the context in which suggested replacement is within a class that implements the Runnable interface. The A class does NOT extend the Thread class. So there is no "isInterrupted" method to be called in this context. The aforementioned correct answer should have it's wording changed to suggest "while(!Thread.interrupted()) {}". This caused me to avoid this answer, because I knew that the Runnable functional interface does not define a default method called "isInterrupted"; and thus one of my answers was marked as incorrect.