Which method needs to be overridden to define the task of a thread?
- execute()
- init()
- run()
- start()
To define the task of a thread in Java, you need to override the run() method. This method contains the code that will be executed when the thread is started. The other methods listed are not used for defining the task of a thread.
Loading...
Related Quiz
- A ________ is a result-bearing computation that can be canceled and can compute the result asynchronously provided by ExecutorService.
- The operator ______ is invalid in Java.
- Consider a case where you have to model a "Book" in a library system. What properties and methods would you define in the Book class and why?
- Which of the following primitive data types has the largest size in memory?
- The process of instantiating a class and creating an object is also known as _______.