chap 1 -revisited Flashcards Preview

Java 1 > chap 1 -revisited > Flashcards

Flashcards in chap 1 -revisited Deck (27)
Loading flashcards...
1

compile time error?

code errors found in compiler

2

logic error?

code does not execute as intended but it does pass the compiler

3

run time error?

code passes the compiler but the program terminates itself abnormally.

4

debugging?

code is checked for logic errors and fixed

5

/* */ --> 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 */

6

/** */ does what?

sends documentation to an external file.

7

main method
what is it?

main method: processing of code begins here but the main method also needs to be preceeded by public, void or static.

8

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.

9

what are Identifiers?

Identifiers: words used when writing programs.

10

to concatenate?

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 + "

11

concatenate a string to numbers how?

just use the + symbol as long as one side is a string then both become a string.

12

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 () .

13

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.

14

what are some escape sequences?

\n new line
\t tab in
\r carriage return
\\ shows a backslash
\" shows a quotation mark

15

Variable?
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.

16

initialization?
example?

initialization is when a variable is given a value for the first time.
String variableName = ("my name");

17

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 = ("");

18

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.

19

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.
example:
fianl int cost = 5;

20

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.

21

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.

22

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.
written as:
variableName++
which means variableName + 1;
works with subtraction too.

23

what are some assignment operators?

! means not
!= means not equal
== means equal
&& logical AND
|| logical OR

24

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.

25

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);

26

what is the scanner class?

used to scan or intake input from the user and assign it to a variable.

27

what are some scanner methods?

Scanner variable will be the following word for this example: scan
scan.next scans in the next information
scan.nextLine scans in the next line
scan.nextInt scans in the next number
scan.nextDouble scans in a decimal
scan.Echo scans in and repeats info to the screen.