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...
1

Input?

data from peripherals, network, file..

2

Process?

computations on data such as adding x + y

3

Output?

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

4

Variables?

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

5

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.

6

what is the definition of an Algorithm?

algorithm: sequence of instructions that solve a problem.

7

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.

8

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.

9

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.

10

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

each statement gets its own line

11

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.

12

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

{
int wage;
wage= 20;
}

13

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

main ( )

14

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

15

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(system.in);
scnr is the object that contains an input device which in this case is a keyboard because system.in is what refers to keyboard in code.

16

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.

17

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

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

18

what is a string lateral?

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

19

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?

system.out.print
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.
system.out.printiln
the lowercase L n stands for newline and tells the program to go to the next line for following commands.

20

are paranthesis always reqwuired around a string literal " " ?

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

21

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

22

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

23

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.
example:
System.out.put("the number of people is =" + AnObjectLikeWAGE);
what will be printed:
the number of people is = wage (aka a number)

24

output statement?

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