Programming Notes
Programming Notes
Topics Covered:
Structure of Java Program
Programming is an art similar to cooking, one must have a good knowledge of all the ingredients and their
features to prepare a delicious dish.
Structure of Java:
Follow the given structure to write any java program, since it increases the readability and makes it clear for
the interviewer about your good programming skills.
} //Main Function
} // End of Class
Class: Class is the outer most covering of a java program which is used to encapsulate the global
variables, user defined functions, and the main function together. (This definition is not based on
OOPs).
Global Variable Section: This section is used to declare the variables which can be accessed freely by
both users defined functions and the main function without any restrictions. (Real world example
would be public Roads, Railways etc. which can be openly accessed by all the citizens without any
restrictions.)
User Defined Functions: In this section the Developer defines and creates his own functions to
perform a particular task.
The above function can be used to print the sum of any two numbers.
add(10,20);
}
There 4 sections are the heart and soul of Java programs. The one who knows to use them optimally will
design and develop one of the best programs in the future.
Example Program:
Output:
Sum=30