Computer Applications
Which of the following statements correctly prints the following output?
Hello
World
Java Intro
3 Likes
Answer
System.out.println("Hello\nWorld");
Reason — Let's analyze each of the options:
1. System.out.println("Hello/nWorld"); — Incorrect
\nis a special escape sequence, but/n(forward slash) is not. Output would be:Hello/nWorld
2. System.out.println("Hello\\nWorld"); — Incorrect
\\nprints as\nliterally (because\\is an escape character for\). Output would be:Hello\nWorld
3. System.out.println("Hello World"); — Incorrect
- Prints everything on a single line. Output would be:
Hello World
4. System.out.println("Hello World"); — Correct
- The
\n(newline escape sequence) moves the cursor to the next line. Output would be:
Hello
World
Answered By
2 Likes
Related Questions
What does the below illustration depict in Java?

- Name of a bird
- DOS based platform for Java programming
- Window based platform for Java programming
- A web browser to execute Java programs
Assertion (A): In Java, when you declare a class, it displays a sample program for the user.
Reason (R): You cannot write a Java program without the use of a sample program.
Based on the above discussion, choose an appropriate statement from the options given below:
- Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A).
- Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of Assertion(A).
- Assertion (A) is true and Reason (R) is false.
- Assertion (A) is false and Reason (R) is true.
James Gosling developed Java programming language.