Intro to Computers & Java Flashcards
Computer program
A sequence of instructions that is executed by a computer to perform a task or solve a problem.
Programming
The act of designing and implementing computer programs.
Algorithm
An unambiguous, executable set of instructions to perform a task or solve a problem.
Machine code
The only instructions that can be processed by a CPU; a stream of binary numbers (1s and 0s). Note, each type of CPU has its own machine language.
Hardware
The physical equipment of a computer.
5 major hardware components of a computer system
- Central Processing Unit (CPU)
- Main memory
- Secondary memory
- Input devices
- Output devices
Central processing unit (CPU)
The heart of the computer that executes the machine instructions.
It is comprised of a Control Unit and the Arithmetic and Logic Unit (ALU). The Control Unit coordinates all of the computer’s operations. It is responsible for determining where to get the next instruction and regulating the other major components of the computer with control signals. The ALU performs mathematic operations. To run a program it follows a fetch/ decode/ execute cycle.
The fetch/ decode/ execute cycle
The process of a CPU running a program.
- Fetch - the Control Unit fetches the next instruction from main memory
- Decode - the instruction is encoded in the form of a number so the Control Unit decides the instruction and generates an electronic signal
- Execute - the signal is routed to the appropriate component of the computer such as the ALU, a disk drive or other device. The signal causes that component to perform an operation.
Main memory / primary storage
Commonly known as random access memory, or RAM, this is a device that holds information. Specifically, RAM holds the sequences of instructions in the programs that are running and the data those programs are using. RAM is usually a volatile type of memory, used only for temporary storage. When the computer is turned off, the contents of RAM are erased.
Memory address
RAM is divided into sections, known as bytes. Each byte is comprised of 8 switches, or bits. Each byte is given an unique number known as an address and all addresses are ordered from lowest to highest like PO Boxes.
Secondary storage
Storage that can hold data for long periods of time and persists without electricity, e.g., a disk drive.
Disk drive
The most common type of secondary storage. A device that stores data by magnetically encoding it onto a spinning circular disk.
Software
The programs that run on a computer. There are two general categories:
- Operating systems - a set of programs that manages the computer’s hardware devices and controls their processes
- Application software - programs that make the computer useful to the user such as word processing
High-level programming languages
A programming language that provides an abstract view of a computer and allows programmers to focus on their problem domain by specifying the overall actions that the program should carry out without having to specify CPU instructions.
Common elements of programming languages
- Key words - reserved words that have a special meaning in a programming language and therefore cannot be used as an identifier by the programmer
- Operators - symbols that denote mathematical or logical operations such as + or &&
- Punctuation
- Identifiers - programmer defined names used to identify storage locations in memory and parts of the program that are created by the developer
- Syntax - rules that define how to form instructions in a paritcular programming language
Compiler
A program that translates source code from a high-level programming language into an executable form (i.e. the more detailed machine language required by the CPU, such as bytecode for the JVM).
Applets
Contrary to an application, which is a standalone program that runs on your computer, an applets is a small application that executes inside a web browser. They are important because they extend the capabilities of HTML by performing mathematical calculations and interacting with the user.
Statements
A syntactical unit in a program (e.g. a complete instruction that causes the computer to perform some action). In Java a statement is either a simple statement, a compound statement, or a block.
Variable
The most fundamental way that a Java stores an item of data in memory is with a variable, or named storage location in the computer’s memory. The data stored in a variable may change while the program is running (hence the name “variable”).
Syntax errors (AKA compile-time errors)
When the compiler translates code into executable form, it uncovers syntax errors in the program. These are errors that the programmer made that violate the rules of the programming language. (i.e. an instruction that does not follow the programming language rules and is rejected by the compiler).
Two primary methods of programming
- Procedural - Programming languages that consist of sets of statements that, together, perform a set of tasks. For example, gather input from a user, manipulate data stored in memory, and perform calculations. In procedural programs data items are passed from one procedure to another. That is the data items that are separate from the procedures, which can lead to problems, since the procedures must be designed for specific types of data. When the structure of data changes, the procedures must be changed or they’ll break.
- Object Oriented Programming - Rather than creating procedures, this is focused on creating objects that contain data and procedures. The data is known as the object’s attributes while the procedures as known as methods.
Encapsulation
The combining of data and code into a single object
Java virtual machine (JVM)
A program that simulates a CPU by reading Java byte code and executing them as they’re read. For this reason, the JVM is often called an interpreter. It’s also what makes Java so portable.
Case sensitive language
A programming language in which car and Car would be two distinct variables. Java is a case sensitive language.
Class
A programmer-defined data type; a template for creating objects. Every program must contain at least one Class.
Method
An action performed by an object of a given class, implemented via a sequence of statements that has a name, may have parameter variables, and may return a value. A method can be invoked any number of times with different values for its parameter variables.
Network
An interconnected system of computers and other devices.
Main method
The method that is first called when a Java application executes and must be present for the program to run.
The method signature is:
public static void main(String[] args)
Argument
A value supplied in a method call (as per the method’s parameters) or one of the values combined by an operator.
String
A sequence of characters
Run-time error
Errors that the compiler won’t find because the program is syntactically correct, but cause it to act differently than intended. Logical errors are examples of run-time errors as well as exceptions such as “division by zero.” It is the responsibility of the programmer to test the program to find and fix any run-time errors.
Logic errors
An error in a syntactically correct program that causes it to act differently from its specification. That is, the program doesn’t produce the intended result. (A form of run-time error.)
Exception
A class that signals a condition that prevents the program from continuing normally. When such a condition occurs, an object of the exception class is thrown.
Portable
A program may be written on one type of computer and then run on a wide variety of computers with little to no modification. Java is highly portable since a compiled Java program can run on any computer that has a JVM.
Library
A set of precompiled classes that can be included in programs
Data hiding
The ability of an object to hide its data from code that’s outside the object. The data may only be accessed and changed by the object’s methods. This protects it from corruption.
API (Application Programming Interface)
A code library for building programs.
Integrated Development Environment (IDE)
A programming environment that includes an editor, compiler, and debugger.