AlgoMaster Logo

Introduction to Java - Quiz

Last Updated: January 13, 2026

1 min read

Introduction to Java Exercises

25 quizzes

1
Multiple Choice

Which best describes Java as a programming language?

2
Multiple Choice

Which keyword starts the definition of a new class in Java?

3
Multiple Choice

Why did Java gain popularity on the early Internet?

4
Multiple Choice

Which Java feature directly supports 'write once, run anywhere'?

5
Multiple Choice

Which component must you install to both compile and run Java programs?

6
Multiple Choice

What is the role of the JRE?

7
Multiple Choice

Which statement about the main method in a Java application is true?

8
Multiple Choice

Which Java feature automatically reclaims memory for objects that are no longer used?

9
Multiple Choice

In the JVM, which component loads .class files into memory?

10
Multiple Choice

Which of these is NOT a core OOP principle emphasized by Java?

11
Multiple Choice

Why is setting PATH to include the JDK's bin directory useful?

12
Sequencing

Order the steps to write, compile, and run a simple Java program from the command line.

Drag and drop to reorder, or use the arrows.

13
Sequencing

Order the stages of how the JVM handles a Java class at runtime.

Drag and drop to reorder, or use the arrows.

14
Output Prediction

What is the output of this code?

1public class Main {
2    public static void main(String[] args) {
3        int a = 5;
4        int b = 3;
5        System.out.println(a + b * 2);
6    }
7}
15
Output Prediction

What is the output of this code?

1public class VersionCheck {
2    public static void main(String[] args) {
3        String name = "Java";
4        int year = 1995;
5        System.out.println(name + " was released in " + year);
6    }
7}
16
Output Prediction

What is the output of this code?

1public class FeatureCount {
2    public static void main(String[] args) {
3        int features = 3;
4        features++;
5        System.out.println("Features: " + features);
6    }
7}
17
Output Prediction

What is the output of this code?

1public class WoraDemo {
2    public static void main(String[] args) {
3        boolean jvmInstalled = true;
4        System.out.println("Can run Java: " + jvmInstalled);
5    }
6}
18
Output Prediction

What is the output of this code?

1public class JvmSteps {
2    public static void main(String[] args) {
3        String step1 = "load";
4        String step2 = "verify";
5        System.out.println(step1.toUpperCase() + "-" + step2.toUpperCase());
6    }
7}
19
Bug Spotting

Find the bug in this Java program that is intended to print Hello, World!

Click on the line(s) that contain the bug.

java
1
public class HelloWorld {
2
    public static void main(String[] args) {
3
        System.out.println("Hello, World!")
4
    }
5
}
20
Bug Spotting

Find the bug preventing this program from running its main method.

Click on the line(s) that contain the bug.

java
1
public class Starter {
2
    public void main(String[] args) {
3
        System.out.println("Starting application");
4
    }
5
}
21
Matching

Match each Java component with its primary responsibility.

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

22
Matching

Match each Java history milestone with its description.

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

23
Fill in the Blanks

Complete the code to compile and run a class named Demo from the command line, shown as comments.

java
1
// Compile the program
2
// Demo.java
3
// Run the program
4
// Demo

Click an option to fill blank 1:

24
Fill in the Blanks

Complete the code to show a simple object-oriented structure with a method call.

java
1
public class Greeter {
2
public void sayHello() {
3
System.out.println("Hello from object");
4
}
5
6
public static void main(String[] args) {
7
Greeter g = new ();
8
g.();
9
}
10
}

Click an option to fill blank 1:

25
Hotspot Selection

Click the line that defines the Java application's entry point.

Click on the line to select.

java
1
public class Starter {
2
    public static void main(String[] args) {
3
        System.out.println("Init");
4
    }
5
}

Premium Content

Subscribe to unlock full access to this content and more premium articles.