• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/32

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

32 Cards in this Set

  • Front
  • Back
  • 3rd side (hint)
All programs can be written in terms of three types of control structures:
sequence, selection, repetition

The ___ statement is used to execute one action when a condition is true and another when that condition is false.
if/else
Repeating a set of instructions a specific number of times is called ___ repetition.
counter-controlled
When it is not known in advance how many times a set of statements will be repeated, a ___ value can be used to terminate the repetition.
sentinal, signal, flag, dummy
The ___ structure is built into Java; by default, statements execute in the order they appear.
sequence
Instance variables of type char, byte, short, int, long, float, and double are all given the value ___ by default.
0
Java is a ___ ___ language; it requires all variables to have a type.
strongly typed
If the increment operator is ___ to a variable, first the variable is incremented by 1, then its new value is used in the expression.
prefixed
T/F An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which they execute.
t
T/F A set of statements contained within a pair of parentheses is called a block.
f
T/F A selection statement specifies that an action is to be repeated while some condition remains true.
f
T/F A nested control statement appears in the body of another control statement.
t
T/F Java provides the arithmetic compound assignment operators +=, -=, *=, and %= for abbreviating assignment expressions.
t
T/F The primitive types (boolean, char, byte, short, int, long, float and double) are portable across only Windows platforms.
f
T/F Specifying the order in which statements execute in a program is called program control.
t
T/F The unary cast operator (double) creates a temporary integer copy of its operand.
f
T/F Instance variables of type boolean are given the value true by default.
f
T/F Pseudocode helps you think out a program before attempting to write it in a programming language.
t
Write down four different Java statements that each add 1 to integer variable x.
x = x + 1; x += 1; ++x; x++;
Write one statement to assign the sum of x and y to z, then increment x by 1.
z = y + x++;
Write a java statement that performs the following: Test whether variable count is greater than 10. If it is, print “Count is greater than 10”.
if(count > 10) outputln(“Count is greater than 10”);
Write a single java statement to decrement the variable x by 1, then subtract it from variable total and store the result in variable total.
total = total - --x;
Write a java statement to calculate the remainder after q is divided by divisor, and assign the result to q. Write this statement in two different ways.
q = q % divisor; q %= divisor;
Declare variable sum of type int and initialize it to 0.
int sum = 0;
int x = 1; Add variable x to variable sum, and assign the result to variable sum.

Declare variable x of type int and initialize it to 1.

int x = 1;

Add variable x to variable sum, and assign the result to variable sum.

sum = sum + x;

Print “The sum is:”, followed by the value of variable sum.

println(String.format(“The sum is: %d”, sum));

Write a run-able java application that calculates and prints the sum of the integers from 1 to 10. Use a while statement to loop through the calculation and increment statements. The loop should terminate when the value of the counter becomes 11. Note: use the space bar to properly indent your code. Begin your code with the line public class Calculate.

public class Calculate


{


public static void main(String[] args)


{


int counter = 1;


while(counter <= 10)


{


sum = sum + counter;


counter++;


}


System.out.println(sum);


} // end main


} // end class

Given that product and x are equal to 5 what will be the values of product and x after the following statement is executed. product=product*x++; After this statement is executed what is the value of product? What is the value of x?
25, 6
What is the error in the following code: while(c <= 5) {product *=c; ++c;
no }
What is the error in the following code: if(gender == 1) System.out.println(“Woman”); else; System.out.println(“Man”);
shouldn’t be ; after else
What is wrong with the following while statement? while (z >= 0) sum +=z;
This is an endless loop where z never gets changed.