Multiple choice general knowledge science & technology

What is the output of following? public class Test { public static void main(String[] args) { new Test(); } public Test() { PrintChar printA = new PrintChar('a', 4); PrintChar printB = new PrintChar('b', 4); printA.run(); printB.run(); } class PrintChar implements Runnable { private char charToPrint; private int times; public PrintChar(char c, int t) { charToPrint = c; times = t; } public void run() { for (int i = 0; i < times; i++) System.out.print(charToPrint); } } }

  1. run-time error

  2. aabbaabb

  3. bbbbaaaa

  4. abababab

  5. aaaabbbb

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

The code creates two PrintChar objects and calls run() directly (not start()). This means they run sequentially in the main thread, not as separate threads. printA.run() completes first (printing 'aaaa'), then printB.run() executes (printing 'bbbb'), resulting in 'aaaabbbb'. The code doesn't actually create multi-threading.