← Quiz: Java Multithreading: all 10 questions
Quiz: Java Multithreading · Question 6 of 10
What does this print? (code)
What does this print?
public class Main {
public static void main(String[] args) {
Thread t = new Thread(() -> System.out.println(Thread.currentThread().getName()), "worker");
t.run();
}
}
- A.worker
- B.main
- C.Thread-0
- D.Nothing
Answer & explanation
Correct answer: main
run() is a normal method call, so the code runs in the current thread (main). Only start() creates the new thread named "worker".
Can you get the rest right without peeking?
Take the timed Quiz: Java Multithreading quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →