Println’s Review

Println’s Review#

These questions are to assess your understanding of printing in Java.

Question 1

True or False: The System.out.print method displays text to the screen and inserts a new line.


Question 2

Which of the following is the correct syntax to output the message “Hello, world!”?

  • System.out.println(Hello, world!);

  • System.println("Hello, world!");

  • System.println.out('Hello, world!);

  • Out.system.println"(Hello, world!)";

  • System.out.println("Hello, world!");


Question 3

What series of System.out.print and System.out.println statements would produce the following output?

Several slashes are sometimes seen,
said Sally. I've said so. See?

Make sure to choose all options that produce the desired output.

Hint: For each print and println statement, track where your cursor is going to be at the end of that statement!

  1.  System.out.print("Several slashes are sometimes seen,");
     System.out.print("said Sally. I've said so. See?");
    
  2.  System.out.println("Several slashes are sometimes seen,");
     System.out.println("said Sally. I've said so. See?");
    
  3.  System.out.print("Several slashes ");
     System.out.print("are sometimes seen,");
     System.out.println("said Sally. I've said so. See?");
    
  4.  System.out.print("Several slashes ");
     System.out.println("are sometimes seen,");
     System.out.println("said Sally. I've said so. See?");
    

Question 4 What is the output of the following series of System.out.print and System.out.println statements:

System.out.print("There's one thing every coder ");
System.out.println("must understand:");
System.out.println("The System.out.println command.");

Write it as you would see on the terminal. (i.e. no quotation marks!)