Complete the code to print "Hello, Java!" to the console.
public class Main { public static void main(String[] args) { System.out.[1]("Hello, Java!"); } }
The println method prints the text and moves to a new line.
Complete the code to declare an integer variable named 'age' with value 25.
public class Main { public static void main(String[] args) { [1] age = 25; } }
In Java, int is the keyword to declare an integer variable.
Fix the error in the code to correctly create a Java class named 'Car'.
public [1] Car { // class body }
Use the keyword class to define a class in Java.
Fill both blanks to declare a method named 'greet' that returns nothing and prints a message.
public [1] greet() { System.out.[2]("Hello!"); }
The method returns void (nothing) and uses println to print with a new line.
Fill all three blanks to declare a Java class 'Person' with a private String field 'name' and a constructor.
public class Person { private [1] [2]; public Person([1] [2]) { this.[2] = [2]; } }
The field is a String named name. The constructor uses the same type and name.
