Flashcards in chap 1 -revisited Deck (27)
compile time error?
code errors found in compiler
code does not execute as intended but it does pass the compiler
run time error?
code passes the compiler but the program terminates itself abnormally.
code is checked for logic errors and fixed
/* */ --> what does this do?
all the comments written between the slashes and asterics is commented out and does not get executed in the code. /* comments here */
/** */ does what?
sends documentation to an external file.
what is it?
main method: processing of code begins here but the main method also needs to be preceeded by public, void or static.
what does the word: void , public or static
mean before main method?
void: means there is no output.
public: means that any program or class can have access to the code in the main method.
-static: means that the data does not change.
what are Identifiers?
Identifiers: words used when writing programs.
concatenate: used to connect two strings together. The plus + sign is used.
--used when a string statement takes up two lines of code within the program.
"code is written here but"
+ " ran out of room so we concatenated them using + "
concatenate a string to numbers how?
just use the + symbol as long as one side is a string then both become a string.
how to not accidentally use concatenation when trying to add two numbers together?
make sure you put the arithmetic within a set of parentheses with a concatenation infront and outside of the () .
escape sequences are?
\ keys allow special characters to be used within the code instead of being seen by the java editor as an action like the end of a string. for instance
\" will show a quotation mark but had the " been used without the slash then the compiler would think it is the start of a string.
what are some escape sequences?
\n new line
\t tab in
\r carriage return
\\ shows a backslash
\" shows a quotation mark
where is it listed usually? what do we call it when we list it?
declare a variable means to just enter the variable name and end it with a ; at the end.
--a variable is a word that is chosen by the programmer to then be called on later in the code.
initialization is when a variable is given a value for the first time.
String variableName = ("my name");
can variables be listed off one after the other if they are the same type such as int or String? if so how?
by using commas.
String variableName, nameTwo, nameThree = ("");
can variables change values?
yes, variables can change values throughout the code as long as it is not marked as a constant, then all caps are used and it is never changed.
what is a constant?
give an example using the integer of 5 as the cost.
a variable that is preceeded with the word final and then the value never changes.
fianl int cost = 5;
primitive data types and what are some?
the amount of ram space is calculated based on the data type chosen. data types have certain things they can represent.
int = positive numbers
String = a list of printable words or numbers within ""
float = decimal point numbers
Boolean = uses true or false only.
what does the arithmetic operators do?
division symbol /
% = will divide a number and only return the remainder as a whole number unless the variable is preceded with float or double.
/ division symbol = division but discards remainders unless a decimal or float is used.
incremental counting is what and how does it work?
or incremental subtraction?
the addition of one each time the variable is called on. often used in do while loops.
which means variableName + 1;
works with subtraction too.
what are some assignment operators?
! means not
!= means not equal
== means equal
&& logical AND
|| logical OR
what is a widening or narrowing conversion and how does it work?
example: float VariableName = int VariableTwo
The decimal value is narrowed (converted) to an integer so the decimal portion is cut off.
how is the scanner class used?
1st import the class: import java.util.scanner;
scanner (variableNameScan) = new object(input source)
scanner scan = new scanner(System.in);
what is the scanner class?
used to scan or intake input from the user and assign it to a variable.