Skip to content
Exercises · Q3

Q.Write a complete Java program that prints your school's name on the screen, and briefly explain the purpose of the main method and System.out.println.

ChseodishaTextbookSubjectiveImportance★★★★★est
23% · 3/13 Questions
✓ Free question

The program:

public class SchoolName {
    public static void main(String[] args) {
        System.out.println("Government Higher Secondary School");
    }
}

How it works, line by line:

  • public class SchoolName { ... } — every Java program must be inside a class. The file is saved as SchoolName.java, matching the public class name.
  • public static void main(String[] args) — this is the main method, the program's starting point. When the program runs, the JVM always looks for main first and begins executing there. If a program has no main, it cannot run.
  • System.out.println("Government Higher Secondary School"); — System.out.println prints the text inside the double quotes to the screen and then moves the cursor to a new line. The statement ends with a semicolon ;.

To run it in an IDE: type the code, press Compile/Build, then Run; the school name appears in the console.

✓Final answer

The program above prints the school name. main is the entry point where execution starts, and System.out.println displays the given text followed by a new line.

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.