Task 7 of 11 · 0 solved · 11 to go0%
You can read the problem, but answers are checked only for signed-in students. Sign in to answer →

1.1 Output — several lines in order

Lesson

Several lines in order

Statements run top to bottom, in the order written. Each println prints its own line, so N println statements make N lines.


Worked example

System.out.println("one");
System.out.println("two");
System.out.println("three");

Three printlns, three lines, in code order: one, two, three.


▶ Try it: run this, then change something and run it again.



Which word is printed first?

System.out.println("one");
System.out.println("two");

How many lines does this print?

System.out.println("a");
System.out.println("b");
System.out.println("c");

Arrange the lines so the program prints red, then green, then blue.


Which word is printed last?

System.out.println("red");
System.out.println("green");
System.out.println("blue");

Type exactly what this program prints.

public class Main { public static void main(String[] a){
    System.out.println("red");
    System.out.println("green");
}}