🎙 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 6 of 10

What does this print? (code)

What does this print?

public class Main {
    public static void main(String[] args) {
        System.out.print("Hi ");
        System.out.print("there");
        System.out.println("!");
    }
}
  1. A.Hi
  2. B.Hi there
  3. C.Hi there!
  4. D.!
Answer & explanation

Correct answer: Hi there!

print does not move to a new line, so all three pieces appear on one line; println ends the line after "!".

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 →