Programming and Problem Solving with Java

(やまだぃちぅ) #1

(^16) | Introduction to Object-Oriented Programming
 A computer can store data into and retrieve data from its memory and secondary
storage (parts of a computer that we discuss in the next section).
 A computer can compare data values for equality or inequality and make
decisions based on the result.
 A computer can perform arithmetic operations (addition and subtraction, for ex-
ample) very quickly.
 A computer can branch to a different section of the instructions.
In addition, a programming language contains instructions, called declarations, which
we use to specify the data and operations in classes. Programming languages require that
we use certain control structuresto organize the instructions that specify the behaviors of
objects. Instructions that describe behavior can be organized in four ways in most pro-
gramming languages: sequentially, conditionally, repetitively, and with subprograms. Java
adds a fifth way: asynchronously (see Figure 1.9).
 A sequence is a series of operations that are executed one after another.
 Selection, the conditional control structure, executes different operations depend-
ing on certain conditions.
Source code
in Java
Computer executes
Java compiler program
Computer executes
C++ compiler program
JVM source
code in C++
Machine language
version of JVM
Bytecode version of
Java code
Loading
Compilation
Execution
Computer executes
machine language
version of JVM to
interpret Bytecode
Computer appears
to execute
Bytecode version
of Java code
Figure 1.8 Compilation and Execution of JVM Combined with Compilation and Interpretation of Bytecode

Free download pdf