Chapter 1 & 2 Flashcards

1
Q

What are computer programs (or software)

A

Computer programs or software are

instructions to the computer

Written using computer languages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the three types of programming languages

A
  1. Machine language (lowest level)
  2. Assembly language
  3. High level language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a program written in a high level source code called

A

Source program or Source code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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?

A

An interpreter or a compiler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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.

A

Interpreter (Interpreting Source Code)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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.

A

Compiler (compiling source file)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why choose Java

A
  • Very useful for deploying internet applications (for servers, desktop, computers, small handheld devices.)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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 _____.

A

bytecode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe the 7 anatomy figures that make up a Java Program

A
  1. Class name
  2. Main method
  3. Statements
  4. Statement terminator
  5. Reserved words
  6. Comments
  7. Blocks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a class name

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the Main Method

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Statement

A

A statement represents an action or a sequence of actions.

The statement System.out.println(“Welcome to Java!”) is “Welcome to Java!“.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Statement Terminator

A

Semicolon ;

(Every statement must end with this)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Keywords

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Blocks

A

A pair of braces in a program forms a block that groups components of a program.

“class block, method block”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

{ }

A
  • Opening and closing braces
  • Denotes a block to enclose statements
17
Q

( )

A
  • Opening and closing parentheses
  • used with methods
18
Q

[ ]

A
  • Opening and closing brackets
  • Denotes an array
19
Q

/ /

A
  • Double slashes
  • Precedes a comment line
20
Q

” “

A
  • Opening and closing quotation marks
  • Marks the end of a statement
21
Q

The four aspects to proper programming and documentation style

A
  1. Appropriate comments
  2. Naming conventions
  3. Proper Indentation and Spacing Lines
  4. Block styles
22
Q

To make appropriate comments, a summary at the beginning of the program must be included, explaining the following:

A
  • what the program does
  • the programs key features
  • the programs supporting data structures
  • any unique techniques it uses
  • also include your name,
  • class section
  • instructor
  • date
  • a brief description at the beginning of the program
23
Q

Naming conventions (classes)

A
  • choose meaningful and descriptive names
  • capitalize the first letter in each word and do this instead of creating spaces between words
24
Q

Indentation and Spacing

A

Indentation: two spaces

Spacing: use blank line to separate segments of the code

25
Q

Block styles

A

Use end of line style for braces

26
Q

Types of programming errors:

A

Syntax errors: detected by the complier

Runtime errors: causes the program to short

Logic errors: produces incorrect result