Java Program Structure

Java Program Structure
Java Program Structure

1. A package is a collection of classes, interfaces and sub-packages. A sub package
contains collection of classes, interfaces and sub-sub packages etc. java.lang.*;
This package is imported by default and this package is known as default package.

2. Import statement is used to import classes of other package in current package.

3. Class is used for developing user defined data type and every java program must start
with a concept of class. Class can extends other class and can implements interfaces.

4. Data member represents either instance or static they will be selected based on the name
of the class.

5. User-defined methods represents either instance or static they are meant for performing
the operations either once or each and every time.

6.Each and every java program starts execution from the main() method. And hence
main() method is known as program driver.
main( ) must be declared as public, since it must be called by code outside of its
class when the program is started.

7.The keyword static allows main( ) to be called without having to instantiate a
particular instance of the class. This is necessary since main( ) is called by the Java
interpreter before any objects are made.

8.The keyword void simply tells the compiler that main( ) does not return a value.
Each and every main() method of java must take array of objects of String.

Comments