Basic Structure of Java program | Unit 1 | Class 11

0

Basic structure of JAVA program

import java.io.*;
public class Kalokalam
{
public static void main(String[] args)
{
System.out.println("Welcome to Kalo-Kalam");
}
}

Explanation:

1. Comments:
Comments are used for explaining code and are used in a similar manner in Java or C or C++. Compilers ignore the comment entries and do not execute them. Comments can be of a single line or multiple lines.

Single line Comments:

Syntax:
// Single line comment

Multi-line comments:
Syntax:

/* Multi line comments*/

2. import java.io.*:
This means all the classes of io package can be imported. Java io package provides a set of input and output streams for reading and writing data to files or other input or output sources.

3. class:
The class contains the data and methods to be used in the program. Methods define the behavior of the class. Class Kalokalam has only one method Main in JAVA.

4. static void Main():
Static keyword tells us that this method is accessible without instantiating the class.

5. void:
Void keywords tell that this method will not return anything. The main() method is the entry point of our application.

6. System.in:
This is the standard input stream that is used to read characters from the keyboard or any other standard input device.

7. System.out:
This is the standard output stream that is used to produce the result of a program on an output device like the computer screen.

8. println():
This method in Java is also used to display text on the console. It prints the text on the console and the cursor moves to the start of the next line at the console. The next printing takes place from the next line.

9. String []args:
This is the argument passed to the main function which is an array of strings with the array name args. One can choose their own flexible name but this name is used by many developers.

Leave a Reply

Your email address will not be published. Required fields are marked *