Define the structure of a JAVA program.
Advertisements
Question
Define the structure of a JAVA program.
Definition
Advertisements
Solution
- Documentation Section: This section contains comments that describe the program, its purpose and other important information.
- Package Statement: It is used to declare the package to which the Java class belongs. It helps in organizing related classes.
- Import Statement: It is used to include predefined classes and packages required in the program.
- Class Declaration: Every Java program contains at least one class. A class is declared using the
classkeyword and contains variables and methods. - Main Method: The
main()method is the starting point of execution in a standalone Java application. It is declared aspublic static void main(String[] args). - Program Statements: These are instructions written inside methods to perform specific tasks such as calculations, input and output operations.
Input:
import java.util.*;
class Hello
{
public static void main(String[] args)
{
System.out.println("Hello Java");
}
}
Output:
Hello Java
shaalaa.com
Is there an error in this question or solution?
