Chapter 1 & 2 Flashcards
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
- Machine language (lowest level)
- Assembly language
- High level language
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
- Very useful for deploying internet applications (for servers, desktop, computers, small handheld devices.)
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
- Class name
- Main method
- Statements
- Statement terminator
- Reserved words
- Comments
- Blocks
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
- The main method is described in
public static void main(String[] args) {
} - In order to run a class, the class must contain a method named main.
- The program is executed from 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”