0 votes
107 views
in JAVA by (98.9k points)
edited
Describe the typical java program structure.

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
Any java program can be written using simple text editor like notepad or
WordPad. The file name should be same as the name of the class used in the
corresponding java program. The extension of the file name should be .java.
FirstProgram.java
/*
This is my First Java Program
*/
class FirstProgram
{
 public static void main(String args[])
 {
 System.out.println(“This is first program”);
 }
}
Explanation:-
In our First Java program, on the first line we have written a comment
statement.This is a multi-line comment.
Then actual program starts with class FirstProgram
Here class is keyword and FirstProgram is a variable name of the class. The
class definition should be within the curly brackets. Then comes
public static void main(String args[])
This line is for function void main().The main is of type public static void.
Public is a access mode of the main() by which the class visibility can be defined
Typically main must be declared as public.
The parameter which is passed to main is String args[]. Hence String is a
class name and args[] is an array which receives the command line arguments
when the program runs,
System.out.println(“This is first program”);
To print any message on the console println is a method in which the string
“This is first program” is written. After println method, the newline is invoked.
Java program is a case sensitive programming language like C or C++.

Related questions

0 votes
0 answers 113 views
asked Aug 9, 2022 in JAVA by Doubtly (98.9k points)
0 votes
1 answer 105 views
asked Jul 31, 2022 in JAVA by Doubtly (98.9k points)
0 votes
1 answer 153 views
asked Jul 20, 2022 in JAVA by Doubtly (98.9k points)
0 votes
1 answer 156 views
asked Jul 20, 2022 in JAVA by Doubtly (98.9k points)
0 votes
1 answer 111 views
asked Aug 9, 2022 in JAVA by Doubtly (98.9k points)

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

557 users

...