0
0
Javaprogramming~10 mins

Java compilation and execution flow - Interactive Code Practice

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

Complete the code to declare the main method in Java.

Java
public class Main {
    public static void [1](String[] args) {
        System.out.println("Hello, world!");
    }
}
Drag options to blanks, or click blank then click option'
Amain
Bexecute
Crun
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method name other than 'main' for the entry point.
Forgetting the exact signature of the main method.
2fill in blank
medium

Complete the command to compile a Java file named Main.java.

Java
javac [1]
Drag options to blanks, or click blank then click option'
AMain.class
BMain
CMain.java
Dmain.java
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to compile a .class file instead of a .java file.
Using wrong capitalization in the filename.
3fill in blank
hard

Fix the error in the command to run the compiled Java program named Main.

Java
java [1]
Drag options to blanks, or click blank then click option'
AMain.java
BMain
CMain.class
Dmain
Attempts:
3 left
💡 Hint
Common Mistakes
Including the .class or .java extension when running the program.
Using lowercase 'main' instead of 'Main' if the class is named Main.
4fill in blank
hard

Fill both blanks to complete the Java compilation and execution commands for a file named App.java.

Java
javac [1]
java [2]
Drag options to blanks, or click blank then click option'
AApp.java
Bapp
CApp
DApp.class
Attempts:
3 left
💡 Hint
Common Mistakes
Using the class file name in the compile command.
Using lowercase or incorrect class name in the run command.
5fill in blank
hard

Fill all three blanks to complete the Java program structure and commands for a class named Demo.

Java
public class [1] {
    public static void [2](String[] args) {
        System.out.println("Demo program");
    }
}

// Compile with: javac [3]
Drag options to blanks, or click blank then click option'
ADemo
Bmain
CDemo.java
Ddemo
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching class name and file name.
Using incorrect method name for main.
Wrong capitalization in file name.