COP2253 Zybooks Chapter One Flashcards
program
consists of instructions executing one at a time
basic instruction types:
input, process, output
input
a program gets data from somewhere
process
a program performs computations on that data, such as adding two values
output
a program puts that data somewhere
variables
used by a program to refer to data
computational thinking
creating a sequence of instructions to solve a problem
algorithm
a sequence of instructions that solves a problem
a program starts in
main(), executing the statements within main’s braces{}, one at a time
each statement typically appears alone on a line and ends with a
semicolon ;
what code at the top of a file enables the program to get input?
import java.util.Scanner;
scanner
a text parser that can get numbers, words, or phrases from an input source such as the keyboard
what statement creates a Scanner object?
Scanner scnr = new Scanner (System.in);
the following statement gets an input value and assigns x with that value:
x = scnr.nextInt();
outputting text is achieved via:
System.out.print(“desired text”);
text in double quotes is known as a
string literal
outputting text with a newline after the outputted values is achieved via:
System.out.println(“desired text”);
outputting a variable’s value is achieved via:
System.out.print(x);
note that no quotes surround x
when outputting multiple items with one statement, items are separated by a
+ symbol
comment
text a programmer adds to a code, to be read by humans to better understand the code, but ignored by the compiler
single-line comment
starts with // and includes all the following text on that line
multi-line (or block) comments
starts with /* and ends with */ and includes all the text in-between
whitespace
blank spaces (space and tab characters) between items within a statement and blank lines (called newlines) between statements
syntax error (a type of compile-time error)
to violate a programming language’s rules on how symbols can be combined to create a program
logic error (run-time error, or bug)
error that occurs as the program runs, even after it has compiled successfully
0s and 1s are known as
bits (binary digits)
processors
execute a list of desired calculations (called instructions)
memory
a circuit that can store 0s and 1s in each of a series of thousands of addressed locations
a programmer created sequence of instructions is called a
program, application, or just app
the processor starts by executing the instruction at location
0
machine instructions
instructions represented as 0s and 1s
executable program
a sequence of machine instructions
assemblers
programs that automatically translate human-readable instructions, known as assembly language instructions, into machine instructions
high-level languages
support programming using formulas or algorithms
compilers
programs that automatically translate high-level language programs into executable programs
bytecode
a compiler-generated executable using machine instructions of a “virtual” processor
virtual machine
executes the instructions in the bytecode
a computer consists of several components
input/output devices, storage, memory, processor, operating system, clock
output device
a screen or monitor displays items to a user
input device
a keyboard (or touchscreen) allows a user to provide input to the computer
storage
a disk (or hard drive) stores files and other data
RAM
RAM (random-access memory) temporarily holds data read from storage
operating system
allows a user to run other programs and interfaces with the many other peripherals
cache memory
a small amount of RAM contained on the processors own chip
clock
governs the rate at which a processor executes instructions
Moore’s law
the doubling of integrated circuit capacity roughly every 18 months (originally 2 years)