Shared Flashcard Set

Details

Midterm 1
CS 302 final
146
Computer Science
Undergraduate 1
10/01/2015

Additional Computer Science Flashcards

 


 

Cards

Term
Major Hardware Components

(6)
Definition
Central processing unit (CPU)
Memory (main memory)
Storage devices (disks and CD)
Input devices (mouse & keyboards)
Output devices (monitors and printers)
communication devices (modems and network interface cards
Term
A computer's components are interconnected by a subsystem called ____

Where is it built into in personal computers?
Definition
bus

the motherboard
Term
CPU

What does it stand for/what does it do?

What components does it have?
Definition
Central processing unit

it's the computer's brain

retrieves instructions from the memory and executes them.

2 components ->
1. control unit - controls and coordinates the actions of the other components.
2. arithmetic/logic unit - preforms numeric operations and logic operations
Term
core
Definition
the part of the CPU that performs the reading and executing of instructions.

a CPU can have more than one core
Term
byte
Definition
the minimum storage unit in a computer

A byte is 8 bits

every byte in the memory has an unique address
Term
bit
Definition
binary digits (1 or 0) that the computer reads
Term
memory
Definition
consists of an ordered sequence of bytes for storing programs as well as data that the program is working with.

the area for executing a program.
a program has to be moved to the memory before it can be executed by the CPU
Term
random access memory
Definition
RAM

bytes in the memory can be access in any order so memory can also be referred to as RAM
Term
hard disk
Definition
used to permanently store data and programs. hard disk drives are encased inside the computer
Term
interpreter/compiler
Definition
translates source code into machine code for execution.
Term
operating system
Definition
most important program that urns on a computer

manages and controls a computer's activities
Term
IDE
Definition
Integrated Development Environment

rapidly developing programs.
Term
API
Definition
Application Program Interface

aka - library
contains predefined classes and interfaces for developing Java programs.

define Java standards
Term
source code
Definition
a program written in a high-level language

because a computer can't execute the program directly (has to go through the compiler)
Term
class
Definition
every Java program has to have at least one class

classes start with a capital letter
Term
string
Definition
data structure
has to be surrounded by double quotes
sequence of characters
Term
statement terminator
Definition
every statement ends with a semi-colon
Term
reserved words or keywords
Definition
have a specific meaning to the compiler and can't be user for other purpose in the program

examples - class, public, static, void
Term
comment
Definition
documents what the program is and how it's built
help programmers communicate with one another

ignored by the compiler

// line comment (one line) //
/* more than one line
yippee */
Term
blocks
Definition
each block begins with an open and ends with a close brace

public class Welcome{
public static void main(String[ ]args) {
System.out.println("Welcome to Java");
}
}
Term
dangling else
Definition
goes to the nearest if
Term
run time error
Definition
an error that causes a program to terminate abnormally
Term
compile error or syntax error
Definition
an error caught by the compiler
Term
logic error
Definition
something that makes the program run unexpectedly
Term
identifiers
Definition
names for naming elements such as variables, constants, methods, classes, and pacakges in a program

CAN"T BE TRUE/FALSE or NULL
Term
identifier
Definition
sequence of characters that consists of letters, digitts, underscores, and dollar signs

AN INDENTIFIER MUST START WITH A LETTER OR UNDRESCORE

can't be a reserved word
Term
variables
Definition
used to store data in a program
declare variable is to tell the compiler what type of data a variable can hold.
Term
assignment operator
Definition
=
Term
named constant or constant
Definition
represents permanent data that never changes

declared using the keyword final
Term
four different integer types
Definition
byte
short
int
long
Term
method naming
Definition
lower case letter for the first word then camel case
Term
class naming
Definition
capital for the first word camel case after that
Term
byte range
Definition
-128 to 127
Term
short type
Definition
-32768 to 32767
Term
int type
Definition
-2147483648 to -2147483647
Term
long type
Definition
-2 ^ 63 to to 2 ^ 63
Term
double type
Definition
8 bytes
Term
float type
Definition
4 bytes
Term
order of operations
Definition
multiplication, division, and remainders are applied first

if multiple occur - leff to right

addition and subtraction are applied last
Term
preincrement
Definition
++var

increment var by 1, and use the new value in the statement

int j = ++i;

int j is 2, i is 2
Term
post increment
Definition
int j = i++
int j is 1 , i is 2

increment var by 1 but use the original var value in the statement
Term
predecrement
Definition
decrement var by 1 and use the new var value in the statement

int j = --i;
j is 0 and i is 0
Term
post decrement
Definition
var --

decrement var by 1 and use the original var value in the statement

int j = i --;
j is 1, i is 0
Term
casting
Definition
an operation that converts one data type into another data type

(newdatatype)variable
Term
overflow
Definition
when the number is too large for the data type value

if you add one to the int max it goes to the negative value
Term
nextLine()
Definition
automatically moves the scanner down after returning the current line
Term
next()
Definition
what comes before the space
Term
selection statements
Definition
statements that let you choose between actions with alternative courses

if/else
Term
boolean expression
Definition
expression that evaluates to true or false
Term
relational operators
Definition
let you compare two things

<
<=
>
>=
==
!=
Term
boolean variable
Definition
is either assigned true or false
Term
if statement
Definition
a construct that allows a program to specify alternative paths of execution

if(boolean expression) {
statements;
}
Term
Math Class
Definition
can be used for generating numbers
Math.random() for generating a random double between 0.0 and 1.0
Term
logical operators
what they are
what it means
Definition
they are -> !, &&, ||, ^ (exclusive or)

when a statement is determined by several conditions these operators help evaluate it to true or false
Term
DeMorgan's Law
Definition
!(condition && condition2) is the same as
!condition1 || !condition2 is the same as
!condition1 && !condition 2
Term
switch statement
Definition
executes statements based on the value of a variable or an expression

checks all cases and executes the statements in the matched case


switch(switch expression) {
case value1: statement1;
break;
case value2: statement2;
break;
}
Term
switch statement rules
Definition
the expression much yield a value of char, byte, short, int or String and must always be in parenths

value1 .. value N must have the same data type as the switch expression

the default case cab be used to preform actions when non of the specific cases match the switch expression

keyword break is option. Immediately ends the switch statement

when the case vallue does match the statements starting from that case are executed until either a break of the end of the switch statement is reached.
Term
conditional expressions
Definition
evaluates an expression based on a condition

if/else

can also be written

boolean-expression ? expression1 : expression2;
Term
hand-trace
Definition
catch errors by reading the program
Term
== vs =
Definition
== is a comparison
= is an assignment
Term
all binary operators are left associative
Definition
assignment operators are right associative
Term
short circuit operators
Definition
also known as lazy operations
&& and ||

because if one if false the statement is false(&&) and if one is true the statement is true (||)
Term
continue statement
Definition
skips the current iteration of a for, while , or do-while loop
Term
nested branches
Definition
seems like besting if/else as well as for loops can be stopped with a break statement

In this case, if condition1 is true then the inner if is executed. If condition1 is false then the nested if is not executed.
if ( condition1 ) {
if ( condition2) {

} else {

}
} else {

}
Term
escape sequence for tab
Definition
\t
Term
escape sequence to have double quotes
Definition
\"String \"
Term
backspace escape sequence
Definition
\b
Term
linefeed
Definition
\n
Term
formfeed
Definition
\f
Term
carriage return
Definition
\r
Term
backslash
Definition
\\
Term
next()
Definition
to read a string from the console, invoke next() on the scanner object

reads a string that ends with a whitespace character
Term
nextLine()
Definition
reads an entire line of text
Term
substring(beginning,end)
Definition
returns this string's substring from the indexes of the first excluding the last
Term
instance methods
Definition
a method that can only be invoked from a specific object
Term
static method
Definition
can be invoked without using an object
Term
while loop
Definition
repeats the statement while the condition is true

syntax

while(loop condition) {
body;
}
Term
counter controlled loop
Definition
when it's known exactly how many times the loop body need to be executed.
Term
infinite loop
Definition
a loop that will continuously run because the condition never becomes false.
Term
off by one error
Definition
the idea that the programmer either runs the condition one less or one too many times than encessary due to the operation

<= instead of <
Term
sentinel value
Definition
the special input value needed to end a loop
Term
sentinel-controlled loop
Definition
a loop design that uses a sentinel value to control it's execution

needs the specific value to end input)
Term
definite loops
Definition
the number of iterations is known before we start exectuing
Term
indefinite loop
Definition
the number of iterations is not known before execution starts
Term
do while loop
Definition
executes the loop body first and then checks the loop continuation condition

syntax

do{
statements;
}while(condition);
Term
for loop
Definition
for (initial value; continuation condition; action after iteration) {
body statements;
}
Term
control variable
Definition
used in for loops and is used to control how many times the body is executed
Term
scope of for loop counter
Definition
within that loop

LOOK THIS UP
Term
event controlled
Definition
when user input or soemthing causes it to be true - specific value
Term
pretest loops
Definition
while and for loops are because the continuation condition is checked before the loop body is executed
Term
post test loops
Definition
do while loop is called this because the condition is checked after the loop body is executed
Term
nested loops
Definition
consisted of an outer loop and one or more inner loops
each time the outer loop is repeated, the inner loops are reentered
Term
method header
Definition
specifies the modifiers, return value type, method name and parameters
Term
value-returning method
Definition
a method that returns a value
Term
void method
Definition
doesn't return a value
Term
actual parameter or argument
Definition
what is passed into the method
Term
method signature
Definition
the method name and the parameeter list together

parameters are optional
Term
activation record
Definition
each time a method is invoked an AR is created taht stores parameters and variables for the method and places the AR in an area of memory known as a call stack.

Call stack stores activation records last-in first out
Term
call stack
Definition
execution stack, runtime stack, or machin stack

when a method calls another method, the caller's activation record is kept intact, and a new activation record is created for the new method called. When a method finished its work and returns to its caller, its activiation record is removed from the call stack.
Term
overloading methods
Definition
enables you to define the methods with the same name as long as their signatures are different.
Term
stepwise refinement
Definition
the process of diving a problem into subproblems to make it more manageable
Term
information hiding or encapsulation
Definition
when teh details fo the implemenation are encapulsated in the method and hidden form teh client who envokes the method
Term
stubs
Definition
a simple but incomplete version of a method
enables you to quickly build the frame work of the program
Term
declaring arrays
Definition
must declare a variable to refernce the array and specify the array's element type

elementType[ ] arrayRefVar;

double[] myList;

can do double myList[]; but the other way is preferred
Term
array initializer
Definition
double[] myList = {valye,value}
Term
int - how many bytes?
Definition
4 bytes in an int
Term
how many bytes in a double
Definition
8 bytes
Term
exception
Definition
an object that represents an error or a condition that prevents execution from proceeding normally

thrown from a method
caller of the method can catch and handle the exception
Term
runtime errors
Definition
occur while a program is running if the virtual machine detects an operation that is impossible to carry out

ex. InputMisMatchException
Term
try-catch bloc
Definition
the code in the try block is what is executed normally
catch block is executed to handle the exception.
Term
throw statement
Definition
the throw statement is analogous to a method call but instead of calling a method, it calls the catch block.

MAIN DIFFERENCE
after the exeception is handled in the catch block the program executes the next statement after the catch (it doesn't go back to the throw statement)
Term
root class for exceptions
Definition
the Throwable Class
Term
exception classes
Definition
three major types

1. system errors
2. exceptions
3 run time exceptions
Term
System errors
Definition
thrown by the JVM and are internal system errors. You can't really do anything to change this you jave to notify your user and exit gracefully
Term
exceptions (compile time exceptions)
Definition
describes errors caused by your program and external circumstances. These errors can be caught and handled by your program.
Term
runtime exceptions
Definition
are represented in the RuntimeException class which describes programming(logic) errors such as bad casting, out of bounds, etc. Gernally thrown by the JVM.
Term
unchecked exceptions
Definition
exceptions the compiler doesn't force the program to deal with. You don't have to have a try/catch block. runtime exceptions are unchecked.
Term
checked exceptions
Definition
the compiler forces the programmer to check and deal with them in a try-catch block or declare it in a method header.
Term
Exception handling model has three operations
Definition
1. declaring an exception
**method2() throws Exception**{
if(an error occurs) {
2. throwing exception
*throw new Exception();*
}
}

method1(){
try{
invoke method2;
} catch(Exception ex) {
3. Catch exception

* Process exception;*
}
}
Term
declaring exceptions
Definition
every method must state the types of checked exceptions it might throw. this is declaring exceptions

if more than one exception ->

public void myMethod() throws Exception1,Exception2,...,ExceptionN
Term
throw exception
Definition
a program that detects an error can create an instance of an appropriate exception type and throw it.
Term
finally clause
Definition
end clause of a try catch block that's always execute whether an exception occurred or not

1. if no exception arises in the try block it's the next thing executed
2. if the statement causes an exception in the try block that is caught in a catch bloc, the rest of the try statements are skipped and the finally clause is executed right after the try statement.

3. if one of the statements causes an exception that is not caught in any catch block the otehr statements in the try block are skipped, the finally clause is executed, and the exception is passed to the caller of this method.
Term
chained exceptions
Definition
when you throw an original excpetion alone with a new exception ( with additional information)
Term
absolute filename (or full name)
Definition
contains a file name with its complete path and and drive letter

machine dependent
Term
relative file name
Definition
in relation to the current working directory.

Welcome.java is a relative filename
Term
File class
Definition
contains the methods for obtaining file and directory properties and for renaming and deteing files and directores

DOES NOT CONTAIN THE METHODS FOR READING AND WRITING FILE CONTENTS.
Term
super class vs subclass
Definition
a subclass (child class) inherits certain attributes from a super (parent class) the sub class can have other methods and attributes as well
Term
extends
Definition
lets the compiler know that one class is inheriting methods from the other

syntax:
subclass superclass
public class Circle extends GeometricObject
Term
private member in superclass
Definition
can't be accessed by any other class.
Term
is-a relationship
Definition
inheritance is used to model this type of relationship

has to fit the phrase subclass is a superclass

A student is a Person
Term
single inheritance
Definition
java doesn't allow multiple inheritance
multiple inheritance can be acheived through interfaces, but NOT IN CLASSES only one class can be a parent.
Term
method overriding
Definition
the method must be defined in the subclass using the same signature and the same return type as its superclass

instance method can only be overridden if its accessible. PRIVATE METHODS CAN'T BE OVERRIDDEN

STATIC METHODS CANT BE OVERRIDDEN
if a static method defined int eh super class is redefined in a subclass, the method defined in the superclass is hidden.

hidden method can be invoked using the syntax SuperClassName.staticMethodName
Term
overloading
Definition
define multiple methods with the same name but different signatures.
Term
implicit casting
Definition
Object o = new Student()

thats okay because an instance of Student is an instance of Object
Term
explicit casting
Definition
you can't just say Student b = o;
because an Object might not be an instance of Student. so the compiler will give an error so you have to be explicit

Student b = (Student) o
Term
upcasting
Definition
it's always legal to cast an instance of a subclass to a variable of a superclass because an instance of a subclass is always an isntance of its supercalss.
Term
downcasting
Definition
explicit casting has to be used because the compiler has to know for sure the object is an instance of the right class.
Term
instanceof
Definition
to check if a object is an instance of the right class you can use the instanceof operator
Term
array list
Definition
can be used to store a list of objects MUST BE AN object so ArrayList is a no go but ArrayList list = new ArrayList<>(); is good
Term
class abstraction
Definition
the separation of class implementation from the use of the class.

details of implementation are encapsulated and hidden from
Term
classes are also known as an abstract data type
Definition
because you can find something out about hte object without knowing exactly how it's executed
Term
stack
Definition
a data structure that holds data in a list-in, first out fashion
Term
wrapper classes
Definition
instances of all wrapper classes are immutable
each numeric wrapper class has named constants
can construct a wrapper object either from a primitive data type value or from a string representing that numerical value.
Term
autoboxing
autounboxing
Definition
the compiler will automatically box a primitve value that appears in a context requiring an object that appears in a context requiring a primitive value.
Term
instantiation
Definition
creating an instance of an object
can create as many as needed
Term
main class
Definition
class that contains the main method.
Supporting users have an ad free experience!