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
उत्तर
class gat– Declares a class namedgat. A class is a basic building block of a Java program.{– Indicates the beginning of the class body.public– It is an access modifier that allows the main method to be accessed by the Java Virtual Machine (JVM).static void main(String args[])– Declares the main method from which program execution begins.staticallows the method to run without creating an object,voidindicates no return value, andString args[]stores command-line arguments.System.out.println("Hello!");– Displays the message Hello! on the screen and moves the cursor to the next line.}– Indicates the end of the main method.}– Indicates the end of the class.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
