🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Java Introduction: all 10 questions

Quiz: Java Introduction · Question 2 of 10

What does this print? (code)

What does this print?

public class Main {
    public static void main(String[] args) {
        System.out.println("A" + 1 + 2);
    }
}
  1. A.A3
  2. B.A12
  3. C.3A
  4. D.Error
Answer & explanation

Correct answer: A12

"A" + 1 gives "A1", then + 2 gives "A12". Text joining happens left to right.

Can you get the rest right without peeking?

Take the timed Quiz: Java Introduction quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →