Complete the code to print "Hello, World!" to the console.
public class HelloWorld { public static void main(String[] args) { System.out.[1]("Hello, World!"); } }
The println method prints the text and moves to a new line, which is the standard way to output text in Java.
Complete the code to declare the main method correctly.
public class Main { public static void [1](String[] args) { System.out.println("Welcome!"); } }
The main method must be named main for the Java program to start execution there.
Fix the error in the class declaration to make it valid Java code.
public [1] HelloWorld { public static void main(String[] args) { System.out.println("Hi!"); } }
The keyword to declare a class in Java is class in lowercase.
Fill both blanks to complete the program that prints a greeting.
public [1] Greeting { public static void main(String[] [2]) { System.out.println("Hello!"); } }
The class declaration uses class and the main method parameter is usually named args.
Fill all three blanks to complete the Java program that prints a message.
public [1] MessagePrinter { public static void main(String[] [2]) { System.out.[3]("Message printed!"); } }
The class keyword is class, the main method parameter is args, and the print method is println.
