🧠 Java Quiz

Java Syntax

Java is precise. Every program has the same skeleton.

The minimum Java program

Every executable Java file has at least:

The Java skeleton
public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Breaking it down

public class Hello — declares a class named Hello. The keyword public means anyone can use this class. The filename must match: Hello.java.

public static void main(String[] args) — the main method, where execution begins:

System.out.println(...) — prints a line to the console.

Statements and blocks

A statement is one instruction. Java statements end with a semicolon:

Statements
int age = 28;
String name = "Raman";
System.out.println(name);

A block groups statements with curly braces. Methods, loops, classes — all use blocks.

Comments

Java has three comment styles:

Comments
// Single-line comment

/* Multi-line
   comment block */

/**
 * Documentation comment (Javadoc).
 * @param args command-line arguments
 */

Case sensitivity

Java is strictly case-sensitive. Name, name, and NAME are three different identifiers. main works; Main doesn't.

Naming conventions

The compiler is your friend Forgot a semicolon? Misspelled a method? The Java compiler refuses to build your code and tells you exactly which line is wrong. Pay attention to those errors — they save you from runtime bugs.