A JAVA program contains many classes but only one class defines a main function. Any type of real world problem can be solved easily with the help of object based concept in JAVA programming. As JAVA is a pure object oriented language, each program in JAVA should start with "class". So JAVA program is only a collection of classes and put them together. A JAVA program contains one or more sections. A JAVA program is basically divided into following section:
Documentation section:
This section contains comment lines. Basically this section comprises author and other related information and all the information about classes and how the program is working so that any user can easily understand the program or, in the maintenance of the program at later stage.
Package statement:
The first statement in JAVA is "package" statement but, it is an optional statement. By this statement, you can declare a "package" or, you can also give the particular "package" name to which the particular class is belonging. Package in a JAVA program are declared as:
Package employee;
Import statement:
After declaring "packages" in program you have to include header files. Header files in a program can be defined by "IMPORT" statement. By "import" statement we can include a particular class of any package. The import statement is declared as:
import employee.Salary;
This statement will include class salary from package employee. You can include any number of classes by "import" statement.
Interface statement:
Interface is a new concept in JAVA programming. This is an optional statement and mainly used when you want to implement "multiple inheritance" in you program. An interface is nothing but simply a class that includes a group of abstract methods. Abstract methods are those methods where body of the method is not declared only the method is declared. With interface, you can call same method from different classes present in different class hierarchies.
Class definition:
Classes are the essential part of a JAVA programming. You can include any number of classes in a single program. But more the number of classes in your program, your program will become more complex. Classes are use to define object which are very close to your real world problem.
Main method class:
This is the most essential part of your program. "MAIN" method is the starting point of your JAVA program. This will create objects of various classes defined in your program and linking between them is done in this section. Main method is the starting point in a Java program and the JVM (Java Virtual Machine) automatically executes the main method first by default. If a main method is not found in any class, then as the program is run, it will show an error message saying no main method was found in the class.
Published by Harsh Gupta - Tech Writer
I am a part time freelancer and writing is my hobby Some of my websites: http://www.GenericArticles.com http://www.JailBreakingiPhone.com View profile
- Laid Off from Work? Negotiate a Severance Package!As the nation's unemployment rate continues to rise, many American families are faced with the financial impact of downsizes and lay-offs. This is an overview of key items to request, in addition to money, as part of...
Understanding JavaA reference guide to all the people who need to learn or understand Java before they begin.- Ruby: An Open Source Programming LanguageRuby is a scripting language that has been around for about 10 years. In the last few years it has picked up some steam.
- Using Java Access Modifiers in Java ProgrammingJava Access Modifiers (also known as Visibility Modifiers) regulate access to classes, fields and methods in Java. These modifiers determine whether a field or method in a class, can be used or invoked by another meth...
- The Real World: Brooklyn on MTV Finally, in 2009, MTV is releasing what we've all been waiting for: The Real World : Brooklyn! Yay!
- Bridging the Gap Between Java and XML
- Features of Java: First Platform Independent Language
- Computer Programming - Then and Now
- JAVA - What You Need to Know About It
- Java Programming Language Tutorial: From Oak to Java
- The 5 Pillars of Java
- Integrating a Foreign Programming Language (VBS)
- Classes are the essential part of a JAVA programming.
- You can include any number of classes in a single java program.
