Chapter 1 sec. 1-2 Flashcards Preview

Java 1 > Chapter 1 sec. 1-2 > Flashcards

Flashcards in Chapter 1 sec. 1-2 Deck (24)
Loading flashcards...


data from peripherals, network, file..



computations on data such as adding x + y



after computations with data, data is put somewhere like a file or screen



Data is held with a placeholder "variable" similar to algebra with X or Y. Each variable is a value or holds a rule


in programming z = x + y means what? is this the same as math?

z = x + Y means it is an assignment: Z is assigned with the sum of X and Y.. in math Z would be equal to what Z and Y are.


what is the definition of an Algorithm?

algorithm: sequence of instructions that solve a problem.


what word and what symbols are used to start a program ?

Main ( ). statements are executed within main's () using their own braces { } one at a time.


what symbols are used within a program ( ) to "house/ hold" the statements that are executed and starts the code to be executed?

{ } are used to execute statements that are inside a program ( ). so main ( ) is used 1st to start the executable code.


instead of a period, what is used to end a statement within a program?

a semicolon ;
The } symbol is only used at the end of all the statements within a program on a line below.


are statements within a program, grouped together or does each get its own line?

each statement gets its own line


how is a variable created? use integer as an example

int Wage
wage is the name of the variable (this is where the variable gets named)
the int tells the program that the word wage represents an integer, aka a number.


using the text below. how would these statements be written in code?
integer = wage
wage = 20

int wage;
wage= 20;


what word/ symbol is used in the code to tell it to start executing the code that follows?

main ( )


how does a program get input for its executable code?

a scanner is used. to create a scanner object.
scanner is a word used in the program to tell it where to get the input from, such as a keyboard


what is a scanner object in code? how is it written?

a scanner object is a placeholder that is represented by an assigned input.
written as:
scanner scnr = new scanner(;
scnr is the object that contains an input device which in this case is a keyboard because is what refers to keyboard in code.


what is a scanner and what is a variable?

scanner = where the program gets its input (keyboard, etc)
variable = a number.
both scanner and variable are used to initiate specifying a custom object that represents a number or an input location.


what does this text do?
system.out.print " "

this command causes whatever is in " " afterwards to print to the screen as output.


what is a string lateral?

string lateral
" "
any text that is contained within quotes.


if a series of commands using system.out.print with string lateral afterwards " " and the words all print on one line.. why is this? what should be done?

construct does support output but when multiple statements are used, even when on their own lines in the code and seporated by ; they will print on the same line.
**the following construct command should be used instead because it causes a new line to be printed on for each construct command.
the lowercase L n stands for newline and tells the program to go to the next line for following commands.


are paranthesis always reqwuired around a string literal " " ?

yes. for text to print then the string literal needs " " surrounded by ( )


what code should be used to type the following sentence on the same line and have it print on the screen?
Hello World!

System.out.print("Hello World!") ;


what is used to print the output of a variable's value? what is the code?

System.out.print(wage) ;
" " are not used because the variable wage, is a number and not a literal string or word. We can also use ln at the end of the command if we need new lines to be printed


what code is used to print the results of several variables with different lines, but in a compact way? is there a shortcut to using system.out.print for each item you want printed?

shortcut or way to combine output statements:
use the plus symbol + between variables to condense the code and make easier to read.
System.out.put("the number of people is =" + AnObjectLikeWAGE);
what will be printed:
the number of people is = wage (aka a number)


output statement?

a line of code that is used to print something to the screen or put out output.