How A Java Program Looks Like?

Class is the heart of java way of development.So when we talk about a structure of java code we will look how a class is structured.
Class contains data members and methods to operate on those data members of the class. Methods contain data type deceleration and executable statements.

A dot operator is used to access the variables and methods of the class.

Structure of a java program:

#Documentation section
#package section
#import statements
#Interface Statements
#class definition
#class member deceleration
#method declaration
#local variable deceleration
A java source code may contain multiple class definitions,multiple member variables, multiple methods,multiple local variables.
Documentation Section:
A set of comment lines that gives the name of the program,the author information and other details. refer this link for information.These are the details the programmers like to refer at a later stage.Comments must explain why and what of classes and how of algorithms.This improves the greater maintainability. The javadoc comment style (/**.....*/) is used for generating documentation automatically.It is optional though.
Package Statement:
The first valid statement of the program.This statement declares a package name and informs the compiler that the classes defined here belong to this package. However if our program does not refer to any other classes,it must be part of default package. This statement is not required then. It is also optional.refer this link for more details.
Import Statement:
After package statement next comes import statements. This statement instruct the interpreter to load the correct class/classes in the package specified.
Interface Statement:
An interface is like a class but includes a group of methods decelerations. This is important when we wish to implement multiple inheritance.However it is also optional.
keywords Statement:
Rest all in the java are 90% keywords. Java keywords have a specific meaning so we can not use them as names for variables,classes , methods,libraries or any other user defined forms.All keywords needs to be written in lower case form(lower case letters). Since java is case sensitive,one can use these words as identifiers by changing one or more letters to uppercase or lower case.However this should be avoided.
How A Java Program Looks Like? How A Java Program Looks Like? Reviewed by Animesh Chatterjee on December 04, 2018 Rating: 5

No comments:

Powered by Blogger.