Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chap 4. Programming Fundamentals

Similar presentations


Presentation on theme: "Chap 4. Programming Fundamentals"— Presentation transcript:

1 Chap 4. Programming Fundamentals
Chapter 4

2 Java Compiling and Execution
Java source code Java bytecode Java compiler Java interpreter Bytecode compiler Runtime Machine code Chapter 4

3 Java Compiling and Execution
The Java compiler translates Java source code into a special representation called bytecode Java bytecode is not the machine language for any traditional CPU Another software tool, called an interpreter, translates bytecode into machine language and executes it Therefore the Java compiler is not tied to any particular machine Java is considered to be architecture-neutral Chapter 4

4 Programming Languages
A program must be translated into machine language before it can be executed on a particular type of CPU This can be accomplished in several ways A compiler is a software tool which translates source code into a specific target language Often, that target language is the machine language for a particular CPU type The Java approach is somewhat different Chapter 4

5 Java Virtual Machine(JVM)
교재 4-8 페이지 참조 An imaginary machine that is implemented by software Provide the hardware platform specification to which all Java code is compiled. Enables Java programs to be platform independent It is up to the Java interpreter of each specific hardware platform to ensure the running of code compiled for the JVM. Chapter 4

6 Java Program Structure
See HelloWorldApp.java A program is made up of one or more classes A class contains one or more methods A method contains program statements A Java application always executes the main method Chapter 4

7 Java program 예: HelloWorldApp.java
// // Sample HelloWorld application public class HelloWorldApp{ public static void main (String args[]) { System.out.println ("Hello World!"); } Chapter 4

8 Java Compiling and Execution
Executing the compiler in a command line environment: > javac HelloWorldApp.java This creates a file called HelloWorldApp.class, which is submitted to the interpreter to be executed: > java HelloWorldApp The .java extension is used at compile time, but the .class extension is not used with the interpreter Other environments do this processing in a different way Chapter 4

9 Errors A program can have three types of errors
The compiler will find problems with syntax and other basic issues (compile-time errors) If compile-time errors exist, an executable version of the program is not created A problem can occur during program execution, such as trying to divide by zero, which causes a program to terminate abnormally (run-time errors) A program may run, but produce incorrect results (logical errors) Chapter 4

10 Using the java Documentation
The layout of this documentation is hierarchical.---> inheritance property Each class document has the same format The main sections of a class document include: The class hierarchy A description of the class and its general purpose A list of member variables A list of constructors A list of methods A detailed list of variables, constructors, methods Chapter 4

11 The Java API The Java Application Programmer Interface (API) is a collection of classes that can be used as needed The println and print methods are part of the Java API; they are not part of the Java language itself Both methods print information to the screen; the difference is that println moves to the next line when done, but print does not Chapter 4

12 Class Libraries The Java API is a class library, a group of classes that support program development Classes in a class hierarchy are often related by inheritance The classes in the Java API is separated into packages The System class, for example, is in package java.lang Each package contains a set of classes that relate in some way Chapter 4

13 The Java API Packages java.applet java.awt java.beans java.io
Some packages in the Java API: java.applet java.awt java.beans java.io java.lang java.math java.net java.rmi java.security java.sql java.text java.util Chapter 4

14 Importing Packages Using a class from the Java API can be accomplished by using its fully qualified name: java.lang.System.out.println (); Or, the package can be imported using an import statement, which has two forms: import java.applet.*; import java.util.Random; The java.lang package is automatically imported into every Java program Chapter 4

15 Java Applets A Java applet is a Java program that is intended to be sent across a network and executed using a Web browser A Java application is a stand alone program Applications have a main method, but applets do not Applets are derived from the java.applet.Applet class Links to applets can be embedded in HTML documents Chapter 4

16 Java Applets local computer Java source code Java compiler Java
bytecode Web browser remote computer Java interpreter Chapter 4

17 Models of Software Design and Development
Staged Delivery Model Design-to-schedule Model Spiral Model Waterfall Model Evolutionary Delivery Model Chapter 4

18 Software Ideas and Concepts Requirement Analysis Architectural Design
Waterfall Model Software Ideas and Concepts Requirement Analysis Architectural Design Detailed Design Coding and Debugging Testing Chapter 4


Download ppt "Chap 4. Programming Fundamentals"

Similar presentations


Ads by Google