Program Structure


Java is an object-oriented, C-based language. Fortran is neither . While some advocates of the more recent versions of Fortran (Fortran 90 and Fortran 95) have tried to pass the language off as being almost object oriented, in truth it models only some object-oriented features but does not directly support such important concepts as inheritance and dynamic dispatching. In addition, Fortran 90 and 95 are built upon legacy versions (Fortran 77 primarily) that aren't object oriented in the least. Java was designed from the ground up to be a true object-oriented language.

One of the big differences between Fortran and Java is the basic program structure of the two languages. A Fortran program consists of a main program section and zero or more subroutines or functions. Program execution starts at the top of the main program section. The main program section is terminated with stop and end statements. Subroutines and functions are terminated with end statements. A Fortran program usually consists of variable declarations and a series of subroutine and/or function calls.

Java is an object-oriented programming language. The fundamental building block of a Java program is a named block of code called a class. Classes are usually designed to be self-contained. They declare fields (i.e., variables ) and methods (the Java equivalent of subroutines) that are used to access and manipulate these fields and perform other functions as well. All statements in a Java program must be placed inside a class or interface.

Classes define the structure of the objects that make Java object oriented. An object is an instance of a class. Java arrays are also objects although no explicit class defines them. An object will have its own copy of the nonstatic data members and methods defined by its class. Java programs will usually declare at least one variable that refers to an object. A Java application can contain more than one class, but one of the classes will declare a main() method. The main() method is the entry point for program execution. The system calls the main() method when the program is run.



Technical Java. Applications for Science and Engineering
Technical Java: Applications for Science and Engineering
ISBN: 0131018159
EAN: 2147483647
Year: 2003
Pages: 281
Authors: Grant Palmer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net