Skip to main content

Java Programe Structure

 Java Programe Structure


    Java class contains may classes but only one class contain main method. Class contain data members and methods that operate on the data members of the class. Method may contend data type declaration and executable statements. To write program, we first need to define classes and then put them together. A java may contain one or more sections.


Document Section:
    The documentation section comprises a set of comment lines giving the name of programes, author details and other details of program. Comments must explain why and what are the cases. This will help in maintaining the program. For single line comment comment programer will use '//' forword slash and for multiline comment programer will use '/* */' syntax.

Package Statement:
    The first statement allowed in a java file is Package statement. This statement declares a package name and inform the compiler that class defined here belong to this package. For example,
    package student;
The package statement is optional.

Import Statement:
    The next thing after a package statement may be number of import statements. For example,
    import student.text;
This statement instructs the interpreter to load the text class contained in the package student. Useing import statement, we can have access to class that part of other name package.

Interface Statement:
    An interface is like a class but includes a group of method declarations. This optional section and use only when programmer wish to implement the multiple inheritance feature in the programe.

Class Definitions:
    Classes are the primary and essential elements of  a java program. These are use to map the object of real-world problems. Programer can use number of classes, it is depend on complexity of the problem.

Main Method Class:
    Every java stand-alone program requires a main method as it's starting point, this is the essential part of java program. The main method creates objects of various classes and establishes communication between them.

Comments

Popular posts from this blog

Decision Making and Branching Statements / Control Statements

 Introduction     Java is a set of statements which executed sequentially in the order in which they appear. This will happen when option or repetitions of certains are not necessary. However, We have a number of situation, where we may have to change the order of execution of statement on bases of certain conditions. This involves a kind of dicision making to see the particular condition occured or not and the direction of execution will execute according to it.     When program braks the sequential flow and jump on the another part of code then it's called branching . When branching is on particular condition then it's called conditional branching . If branches executes without any particular conditions then it's call unconditional branching .     Java supports such decision making capabilities and supports following statements known as Control statement or Decision making statement .     if statements     switch statement   ...