Which of these statement is incorrect?
A. A thread can be formed by implementing Runnable interface only
B. A thread can be formed by a class that extends Thread class
C. start() method is used to begin execution of the thread
D. run() method is used to begin execution of a thread before start() method in special cases
Answer: Option D
Solution (By Examveda Team)
Option A is correct: You can create a thread by implementing the Runnable interface. Your class provides the run() method, which contains the code the thread will execute.Option B is correct: You can also create a thread by extending the Thread class. This is another way to define what the thread will do within the run() method.
Option C is correct: The start() method is crucial. It's what actually initiates the thread's execution. It prepares the thread and then calls the run() method in a separate thread of execution.
Option D is incorrect: You should never call the run() method directly to start a thread. Calling run() directly simply executes the code within the run() method in the current thread, rather than creating a new thread. To properly start a thread, you must use the start() method.
Join The Discussion
Comments (1)
A. A lightweight process that runs independently within a program
B. A data structure to store variables
C. A type of loop
D. A synchronization mechanism
Which interface is used to create a thread in Java?
A. Processor
B. Executor
C. Threadable
D. Runnable
What is the main advantage of using multithreading in Java programs?
A. Reduced memory usage
B. Simplicity of code
C. Improved program performance by utilizing multiple CPUs or CPU cores
D. Elimination of exceptions
How can you create a new thread in Java by implementing the Runnable interface?
A. Create an object of the Thread class
B. Create a class that implements the Runnable interface and override the run() method
C. Use the start() method of the main thread
D. None of These

A and D both are wrong