Task 1 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 — your first program

Lesson

What a Java program looks like

Every Java program lives inside a class. Inside the class there is a special method called main — that is where the computer starts. Your instructions go inside main, one statement per line, and they run from top to bottom.


Worked example

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello");
    }
}

Three layers: the class, then main inside it, then your statement inside main. The braces { } mark where each layer begins and ends. In the practice tasks this skeleton is already typed for you — you add the lines inside main.


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



Where does the computer start running the program?


Where do your own statements go?


What do the braces { } do?


True or false?


Type exactly what this program prints.

public class Main {
    public static void main(String[] args) {
        System.out.println("Go");
    }
}