0
0
Javaprogramming~10 mins

Writing first Java program - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print "Hello, World!" to the console.

Java
public class HelloWorld {
    public static void main(String[] args) {
        System.out.[1]("Hello, World!");
    }
}
Drag options to blanks, or click blank then click option'
Aprintln
Bprint
Cwrite
Doutput
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of println may not add a new line after output.
2fill in blank
medium

Complete the code to declare the main method correctly.

Java
public class Main {
    public static void [1](String[] args) {
        System.out.println("Welcome!");
    }
}
Drag options to blanks, or click blank then click option'
Aexecute
Bmain
Crun
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using other method names like start or run will not run the program automatically.
3fill in blank
hard

Fix the error in the class declaration to make it valid Java code.

Java
public [1] HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hi!");
    }
}
Drag options to blanks, or click blank then click option'
Aclass
BClass
Cmethod
Dfunction
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase Class causes a syntax error.
4fill in blank
hard

Fill both blanks to complete the program that prints a greeting.

Java
public [1] Greeting {
    public static void main(String[] [2]) {
        System.out.println("Hello!");
    }
}
Drag options to blanks, or click blank then click option'
Aclass
Bargs
Cargv
DClass
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase Class or argv instead of args.
5fill in blank
hard

Fill all three blanks to complete the Java program that prints a message.

Java
public [1] MessagePrinter {
    public static void main(String[] [2]) {
        System.out.[3]("Message printed!");
    }
}
Drag options to blanks, or click blank then click option'
Aclass
Bargs
Cprintln
DClass
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase Class, argv, or print instead of println.