Structure Of The Java Program
1. When we are writing any program in any language we need to follow a standard
format for writing the program which is prescribed by language developers.
2. Sun micro system has prescribed the following standard formats for development of
java applications.
format for writing the program which is prescribed by language developers.
2. Sun micro system has prescribed the following standard formats for development of
java applications.
Package details:
Class <class name>
{
Data members;
User-defined methods;
Public static void main (String args[])
{
Block of statements;
}
}
Class <class name>
{
Data members;
User-defined methods;
Public static void main (String args[])
{
Block of statements;
}
}
Explanation: -
1. In the above structure we know that a package is a collection of classes, interfaces
and sub packages, as a java programmer if we use any pre-defined classes and
interfaces in the java program then it is the responsibility of the java programmer to
specify in which package the classes and interface presents. In java programming by
default java.lang.* to each and every java program.
2. Class is a keyword used for developing user/programmer defined data types. Each
and every java program must starts with a concept of class.
3. <class name> represents java valid variable name and it is treated as class name.
Every class name is treated as one kind of user/defined data type.
4. Data Members represents either instance (or) static and they will be selected
depends on class name.
5. User-defined methods represents either instance (or) static and they will be
selected depends on the class name and these methods are used for performing
the operations either once (or) repeatedly. All the user-defined methods of a class
contain logic for solving client requirement/problem. These methods are known as
Business logic methods.
6. Each and every java program starts its execution from main() hence main() is
known as Program Driver.
7. Since main() is not retuning any value and hence its return type must be void.
8. Since the main() executes only once throughout, the life of entire java program and
hence its nature must be static.
9. Since main() is access in all the java programs and hence its access specifier must
be public (universal access)
10. Each and every main() of java must take array of objects of String class.
11. The block of statements represents set of executable statements which are meant
for calling user-defined methods of the class (Business logic).
12. The file naming convention in java programming is that whichever class name is
containing main(), that class name will be given as file name with an extension dot
java(.java).
1. In the above structure we know that a package is a collection of classes, interfaces
and sub packages, as a java programmer if we use any pre-defined classes and
interfaces in the java program then it is the responsibility of the java programmer to
specify in which package the classes and interface presents. In java programming by
default java.lang.* to each and every java program.
2. Class is a keyword used for developing user/programmer defined data types. Each
and every java program must starts with a concept of class.
3. <class name> represents java valid variable name and it is treated as class name.
Every class name is treated as one kind of user/defined data type.
4. Data Members represents either instance (or) static and they will be selected
depends on class name.
5. User-defined methods represents either instance (or) static and they will be
selected depends on the class name and these methods are used for performing
the operations either once (or) repeatedly. All the user-defined methods of a class
contain logic for solving client requirement/problem. These methods are known as
Business logic methods.
6. Each and every java program starts its execution from main() hence main() is
known as Program Driver.
7. Since main() is not retuning any value and hence its return type must be void.
8. Since the main() executes only once throughout, the life of entire java program and
hence its nature must be static.
9. Since main() is access in all the java programs and hence its access specifier must
be public (universal access)
10. Each and every main() of java must take array of objects of String class.
11. The block of statements represents set of executable statements which are meant
for calling user-defined methods of the class (Business logic).
12. The file naming convention in java programming is that whichever class name is
containing main(), that class name will be given as file name with an extension dot
java(.java).
Visitors