What are computer programs (or software)
Computer programs or software are
instructions to the computer
Written using computer languages.
What are the three types of programming languages
What is a program written in a high level source code called
Source program or Source code
Because computers cannot understand a source program, a source program must be translated into machine code for execution.
What programming tool can you use for the translation?
An interpreter or a compiler
An _____ reads one statement from the source code, translates it to the machine code or virtual machine code, and then executes it right away, as shown in the following figure.
Note that a statement from the source code may be translated into several machine instructions.
Interpreter (Interpreting Source Code)
A _____ translates the entire source code into a machine-code file, and the machine-code file is then executed, as shown in the following figure.
Compiler (compiling source file)
Why choose Java
You can port a source program to any machine with appropriate compilers. The source program must be recompiled, however, because the object program can only run on a specific machine. Java was designed to run object programs on any platform.
With Java, you write the program once, and compile the source program into a special type of object code, known as _____. The _____ can then run on any computer with a Java Virtual Machine which is software that interprets Java _____.
bytecode
Describe the 7 anatomy figures that make up a Java Program
What is a class name
A class is something that every Java program needs to run within
Every Java program must contain at least 1
Class names must begin with an uppercase letter
What is the Main Method
Statement
A statement represents an action or a sequence of actions.
The statement System.out.println(“Welcome to Java!”) is “Welcome to Java!“.
Statement Terminator
Semicolon ;
(Every statement must end with this)
Keywords
Keywords are words that have a specific meaning to the compiler and cannot be used for other purposes in the program.
For example, when the compiler sees the word class, it understands that the word after class is the name for the class.
Blocks
A pair of braces in a program forms a block that groups components of a program.
“class block, method block”
{ }
( )
[ ]
/ /
” “
The four aspects to proper programming and documentation style
To make appropriate comments, a summary at the beginning of the program must be included, explaining the following:
Naming conventions (classes)
Indentation and Spacing
Indentation: two spaces
Spacing: use blank line to separate segments of the code