Term
|
Definition
gives a variable a value i.e. product = 1; |
|
|
Term
|
Definition
a place in the computer that can hold a value. A name by which you can store and retrieve data |
|
|
Term
|
Definition
a part of a for-loop this is the part that actually gets executed |
|
|
Term
|
Definition
run together two or more items |
|
|
Term
elements of a good program |
|
Definition
1. solves a general program 2. it is readable; easy to understand and modify 3. it is robust; works in a wide range of circumstances 4. it is efficient; it runs fast and uses little memory 5. it is practical; it can be developed within given constraints, such as time to develop, running on a given machine, developed within a certain monetary budget. |
|
|
Term
|
Definition
a way to repeatedly execute one or more statements |
|
|
Term
|
Definition
how many times to execute the body has 3 parts: -initialization -test -update |
|
|
Term
|
Definition
part of a for-loop. says what to do before executing the body for the first time. eg. i = 1 will set the variable i to have the vaule 1 |
|
|
Term
|
Definition
a request to an object to perform some task |
|
|
Term
|
Definition
strings of characters enclosed in double quote marks |
|
|
Term
|
Definition
part of a for-loop this is checked before executing the body at each iteration. If true, execute body; if false, drop out of the loop |
|
|
Term
|
Definition
part of a for-loop. this is executed after executing the body. eg. i++ will increment the variable i |
|
|
Term
What do you write at the top of each program? |
|
Definition
public static void main(String args[]) |
|
|
Term
|
Definition
eg. n = input.nextInt(); nextInt() is the method call. Basically says: use the method called nextInt from the Scanner class on the object called input (Scanner input = ..) was used to initialize input first |
|
|
Term
|
Definition
refers to what most other programs call a "function" |
|
|
Term
|
Definition
|
|
Term
|
Definition
two (three) types: primitive data type and objects (and references) |
|
|
Term
|
Definition
rules: Begins with a letter, _, or $. It is composed of any number of letters, digits, underscores or dollar signs. Note: Java is case sensitive. |
|
|
Term
conventions for identifiers |
|
Definition
Classes: Title case. The first letter of each word is capitalized. Variables: start with lowercase, then all other words are capitalized. |
|
|
Term
|
Definition
declaring a variable does 2 things: 1. creates a place in memory to put the variable, gives it a name, and establishes the correspondence between the name of the variable and its address in memory. 2. says what kind (type) of value you'll find there |
|
|
Term
|
Definition
|
|
Term
|
Definition
initialized with "final" before the type assignment. Convention is to use all capital letters. This variable cannot be overwritten within the class. |
|
|
Term
|
Definition
The type of data tells us: the possible values it can have, how it's stored in the computer, and which operations on he data make sense. Integer, Character, Boolean, Floating |
|
|
Term
|
Definition
2 Bytes (16 bits). It can hold a signed integer between -32,768 and +32,767 (-2^15 & +(2^15)-1) |
|
|
Term
|
Definition
Most common integer type. 4 bytes (32 bits). Can hold a signed integer from -2,147,483,648 to +2,147,483,647 |
|
|
Term
|
Definition
1 byte (8 bits) holds values between -128 and 127 |
|
|
Term
|
Definition
8 bytes (64 bits) Holds integer values between -9,223,372,036,854,775,808 and 9,223,372,036,854,773,807 |
|
|
Term
|
Definition
When you use a specific number in your program it is called a literal. For example, an integer literal consists of a sequence of digits with no commas. Leading zeroes are not allowed. + and - aren't included in the literal but may precede it. If they are of type long they will followed by an L or l. |
|
|
Term
|
Definition
2 bytes (16 bits) represents 65,536 characters character literals are enclosed in single quotes 'l' |
|
|
Term
|
Definition
can take on the values true and false only. Cannot be converted to other types, nor can other types be converted to boolean. |
|
|
Term
|
Definition
stored like scientific notation; with three parts: 1. a sign, + or -; 2. a mantissa, eg. 6.02; 3. an exponent, eg. 23. For numbers with fractional parts or that are too long to store in a long (or both). |
|
|
Term
|
Definition
8 bytes. can store values in the range +/-4.9*10^-324 to +/-1.8*10^308 with 15 sig figs |
|
|
Term
|
Definition
4 bytes .: smaller range of exponents +/-1.4*10^-324 to +/-3.410^38 with 7 sig figs. Uses less space than a double. |
|
|
Term
Why use int at all since double is so flexible? |
|
Definition
1. computing with floating types is slower than computing with integer types 2. Precision. There are some integer values that you cannot store in a double and if you try, weird things happen. |
|
|
Term
when representing integers as doubles weird things can happen. What are they? |
|
Definition
1. Just like 1/3 cannot be represented as a decimal point, many numbers (eg. 0.1) cannot be represented exactly as a double 2. Problems arise when large numbers are added to or subtract from small numbers...i.e. "roundoff error" -- more sig figs than available in double might be needed |
|
|
Term
|
Definition
i.e. we have three digits but add 1 + 999....the result will be a negative number that doesn't seem to make sense. |
|
|
Term
|
Definition
+, -, *, / note: no % or modulus...division is just division |
|
|
Term
|
Definition
order of number types: byte -> short -> int -> long -> float -> double going from left to right is called widening; sometimes Java will do this for you. |
|
|
Term
|
Definition
in order to narrow you must explicitly ask for a conversion, or cast. This is done by putting the type in parentheses before the value to be converted. |
|
|
Term
|
Definition
there are a couple specially-written characters: \n - succeeding output goes on a new line; \ - escape character. It indicates that something special follows it. \t - tab "\"" = " |
|
|
Term
|
Definition
to take input from the keyboard, we must import the java scanner class: import java.util.Scanner; And then create a new scanner object: Scanner input = new Scanner(System.in); When calling input (reference to a scanner class) we must indicate what type of input we expect: String token = input.nextInt(); |
|
|
Term
|
Definition
the object that the reference points to contains: Some data (possible a lot, possibly none) Some methods that operate on the data |
|
|
Term
|
Definition
like a blueprint for creating objects. It says what all objects created from the blueprint have in common. |
|
|
Term
|
Definition
class = blueprint object = house instantiate = build |
|
|
Term
|
Definition
Formats doubles to a specific number of decimal places. Relies on the String class eg: import java.text.DecimalFormat; DecimalFormat fmtA = new DecimalFormat("0.###"); fmtA.format(area); |
|
|
Term
|
Definition
when two references are to the same object |
|
|
Term
|
Definition
If the type at instantiation is a class, the variable is a reference. If it is a primitive type (eg. int, double, long) it's type is that type. |
|
|
Term
|
Definition
object = thing method = action .: noun.verb(parameters) |
|
|
Term
|
Definition
A String object is just like any other object, except: 1. String objects are immutable: once they are created they cannot be changed. You would have to make a new String that is like the old on, but with whatever change you wanted 2. When either operand to the + operator is a reference to a String then + means concatenation. Java will automatically cast operands that are not string references into string references before concatenation (as long as one operand is). |
|
|
Term
Class Methods or Static Methods |
|
Definition
unlike methods for other classes (DecimalFormat or String), class methods are not called by means of a reference to an individual object. There is no objects involved unless one is supplied as a parameter. |
|
|
Term
|
Definition
j++ -> j = j + 1 i = j++ -> i = j & j = j + 1 i = ++j -> i = j + 1 & j = j + 1 |
|
|
Term
Combined Assignment with Operations |
|
Definition
j += 2 -> j = j + 2 x *= 2 -> x = x * 2 |
|
|
Term
|
Definition
enum DayOfWeek {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}; DayOfWeek day = DayOfWeek.Thursday Enumerated type = class with a given number of constants. E-types have ordinal values, from 0 up, and the method ordinal gives you that value. (eg: if day = DayOfWeek,Thursday then day.ordinal = 4; day.name() = Thursday) |
|
|
Term
|
Definition
Allows us to repeatedly perform an action as long as a condition evaluates to the boolean value "true" while (condition){ statement; }
1. Evaluate the condition. If it's true, then execute the body. 2. Having executed the entire loop body, evaluate the condition again. If it is true, then execute the body again. 3. Continue on, evaluating the condition and executing the body until the condition evaluates to false. 4. Once the condition evaluates to false, transfer control to the first statement following the loop. |
|
|
Term
|
Definition
A while loop that never evaluates to false. |
|
|
Term
|
Definition
Special case of a while loop. Allows for a more graceful and readable form to certain types of while loops. for (initialization; condition; update) statement;
Generally: uses a counter variable to go either up or down until the loop has ended. (there are other examples) |
|
|
Term
|
Definition
similar to a while loop, except that the test occurs AFTER each iteration such that the loop must be executed at least once. do statement; while (condition);
1. Execute the loop body 2. Evaluate the condition. If it's true, then execute the loop body 3. Evaluate the condition again. If it's still true, then execute the loop body 4. Continue as long as the condition evaluates to true 5. Once the condition is false, transfer control to the first statement following the loop |
|
|
Term
|
Definition
Used in one of two situations: 1. if you want to perform an action (or sequence of actions) when a condition holds, and don't perform that action when the condition doesn't hold 2. If you want to perform an action (or sequence of actions) when a condition holds, but perform a different action (or sequence) if the condition doesn't hold |
|
|
Term
|
Definition
evaluate to TRUE or FALSE: == != < <= > >= |
|
|
Term
to find out if two strings are equal... |
|
Definition
Do no use boolean operators. Use: .equals .equalsIgnoreCase .compareTo |
|
|
Term
|
Definition
! - negates its operand && equals true if both operands are true, false otherwise ("logical and") || true if either operand, or both operands are true and false if both are false ("logical or", "inclusive or") |
|
|
Term
|
Definition
statements which first evaluate the left operand, if the result can be evaluated from the left operand, the left is not evaluated. |
|
|
Term
Benefits of using classes and objects |
|
Definition
1. they provide abstraction 2. they provide a set of "parts" that you can use at will |
|
|
Term
|
Definition
the only way that users of a class should interact with objects in that class. These are functions provided by the class |
|
|
Term
|
Definition
creates an object of a given class returns a reference to the object created stores the reference into a variable that has been declared as a reference to an object of the appropriate class |
|
|
Term
|
Definition
special method of a class gets called at the same time as we instantiate the object it has the same name as the class the designer of the class has the option of passing parameters to the constructor that allow it to customize the object being produced. Returns nothing: void |
|
|
Term
|
Definition
a program whose purpose is to exercise some other piece of code the main method of a driver doesn't really do anything interesting. |
|
|
Term
|
Definition
variables that are associate with a particular object and each object created using the class will have its own copies of them |
|
|
Term
|
Definition
The use of private before methods or instance variables means that only methods within the current class can access them...i.e. they are hidden |
|
|
Term
|
Definition
there are multiple method with the same name but different parameters |
|
|
Term
|
Definition
the name of the method and the number, types, and order of its parameters. |
|
|
Term
|
Definition
a variable that is declared within a method. it exists only within the method in which it is declared. .: two methods can have local variables with the same name, and these are COMPLETELY different variables |
|
|
Term
|
Definition
converts an int to a reference to a string representing that integer |
|
|
Term
|
Definition
does two things: 1. computes a value to be sent back to the caller 2. immediately transfers control back to the caller |
|
|
Term
|
Definition
part of a program where a variable or method name is known. 1. Scope of an instance variable, class variable, or method name is the entire class that contains it plus, if it's public, the entire rest of the package. 2. The scope of a formal parameter is the body of its method. 3. The scope of a variable declared in a for-loop header is the rest of the for-loop header and loop body. 3. Otherwise, the scope of a variable is everything following its declaration and within the curly braces around it. 5. If a local variable has the same name as an instance or class variable, the local variable prevails within its scope. |
|
|
Term
|
Definition
The region of memory that is allocated to keep track of information about a call of a method. This is where the local variables for that method reside. |
|
|
Term
|
Definition
Stack frames are organized into a stack. This contains information about all the methods that are in the midst of executing. The stack contains one stack frame for each method that has been called but that has yet to return. |
|
|
Term
|
Definition
When you call a method, a new stack frame is pushed onto the stack, at the bottom. |
|
|
Term
|
Definition
whenever a method returns to its caller, the called method's stack frame is popped off the stack, or removed. |
|
|
Term
|
Definition
The memory occupied by objects come from here, this is separate from the stack. |
|
|
Term
|
Definition
the parameters that appears in a method definition. OR formal parameters are local variables that happen to be initialized according to the values of the corresponding actual parameters at the point of call. |
|
|
Term
|
Definition
The parameters that appear at the point of call (aka arguments). |
|
|
Term
|
Definition
variables declared within a method. They appear within the stack frame for that method |
|
|
Term
|
Definition
After a method has been popped, all references to objects are gone. The objects that are left are eligible for garbage collection, that is the Java runtime sustem has the option of reclaiming the memory used by that object, thus making it available for reuse. |
|
|
Term
|
Definition
not called by means of a reference to an individual object. There is no object involved (unless given as a parameter). Instead of a reference to the left of the dot we put the name of the class containing the static method (eg. Math.min, Math.max) |
|
|
Term
|
Definition
there is only one copy of these and it is shared among all objects in the class. Differs from an instance variable in that each object gets its own copy of an instance variable. |
|
|
Term
|
Definition
provide methods that we can run on primitive types. |
|
|
Term
|
Definition
an automatic way of converting a primitive type into an object of its corresponding wrapper class. i.e. int = x; Integer intx = x; |
|
|
Term
|
Definition
a way of automatically converting an object of a wrapper class into a value of its corresponding primitive type. i.e. Integer intx = new Integer(17); int x = intx; |
|
|