हिंदी

Explain each line in the following program: class gat { public { static void main(string args[ ]) System.out.println("Hello!"); } }

Advertisements

प्रश्न

Explain each line in the following program:

class gat
{
public
{
static void main(string args[ ])
System.out.println("Hello!");
}
}
दीर्घउत्तर
Advertisements

उत्तर

  1. class gat – Declares a class named gat. A class is a basic building block of a Java program.
  2. { – Indicates the beginning of the class body.
  3. public – It is an access modifier that allows the main method to be accessed by the Java Virtual Machine (JVM).
  4. static void main(String args[]) – Declares the main method from which program execution begins. static allows the method to run without creating an object, void indicates no return value, and String args[] stores command-line arguments.
  5. System.out.println("Hello!"); – Displays the message Hello! on the screen and moves the cursor to the next line.
  6. } – Indicates the end of the main method.
  7. } – Indicates the end of the class.
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 3: Programming in Java (Review of Class XI Sections B and C) - EXERCISE [पृष्ठ ९८]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
अध्याय 3 Programming in Java (Review of Class XI Sections B and C)
EXERCISE | Q 17. | पृष्ठ ९८
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×