a for loop normally performs which of these steps?

a for loop normally performs which of these steps?


S
Asked by 2 years ago
9.9k points
If variable int max represents the maximum value of a set of input values, the best initial value for max would be: a. 0 b. the first input value c. a very large number d. a very small numberb. the first input value
A sentinel value _________ and signals that there are no more values to be entered. a. is a different data type than the values being processed b. is a special value that cannot be mistaken as a member of the list c. indicates the start of a list d. guards the listb. is a special value that cannot be mistaken as a member of the list
When you pass the name of a file to the PrintWriter constructor and the file already exists, a. it will be erased and a new empty file with the same name will be created. b. an IOException will be thrown. c. a new empty file will be created with the same name and a different version number. d. the file will be opened and new data will be appended to its current contents.a. it will be erased and a new empty file with the same name will be created.
What will be the value of x after the following code is executed? int x = 10; while (x < 30) { x += 10; } a. 20 b. 30 c. 40 d. This is an infinite loopb. 30
A for loop normally performs which of these steps? a. initializes a control variable to a starting value b. tests the control variable by comparing it to a maximum/minimum value and terminate when the variable reaches that value c. updates the control variable during each iteration d. all of the aboved. all of the above
If the main method calls method A, and method A calls method B, what happens when method B finishes? a. control is returned to the main method b. control is returned to method A c. an IOException is thrown d. the program terminatesb. control is returned to method A
In the following code, what values could be read into number to terminate the while loop? Scanner keyboard = new Scanner(System.in); System.out.print("Enter a number: "); int number = keyboard.nextInt(); while (number < 100) { System.out.print("Enter another number: "); number = keyboard.nextInt(); } a. Numbers less than 100 b. Numbers in the range 100 - 499 c. Only 100 d. The boolean condition can never be trueb. Numbers in the range 100 - 499
What will be the value of x after the following code is executed? int x = 10; for (int y = 1; y = 0 && sales < 7499) bonus = 25; if (sales >= 7500 && sales = 10000) bonus = 500; a. 100 b. 500 c. 25 d. 0a. 100
What will be the value of bonus after the following code is executed? int bonus; int sales = 10000; if (sales < 5000) bonus = 200; else if (sales < 10000) bonus = 750; else if (sales < 20000) bonus = 1000; else bonus = 1250; a. 200 b. 750 c. 1000 d. 1250c. 1000
Which of the following expressions will determine whether x is less than or equal to y? a. x > y b. x =< y c. x = yc. x = y + 1) ans = y; else ans = x; a. 2 b. 3 c. 0 d. No value, there is a syntax errora. 2
int x; int y; int ans; Assume that x has been initialized to 2, y to 3, and ans to 0. What will be the value of ans after the following code has been executed? if (x == y) ans = 2 * x; a. 4 b. 6 c. 0 d. No value, there is a syntax errorc. 0
int x; int y; int ans; Assume that x has been initialized to 2, y to 3, and ans to 0. What will be the values of ans, x, and y after the following statements are executed? if ( x >= y) { ans = 10; x = 1; } else { ans = 20; y = 1; } a. ans = 0, x = 2, y =3 b. ans = 10, x =1, y =3 c. ans = 20, x = 2, y = 1 d. ans = 20, x = 1, y = 3c. ans = 20, x = 2, y = 1
To do a case insensitive compare which of the following could be used to test the equality of two strings, str1 and str2? a. str1 b. str2 c. both can be usedc. both can be used
This type of operator determines whether a specific relationship exists between two values:Relational
This is a boolean variable that signals when some condition exists in the program.Flag
A Boolean expression is one that is either:true or false
In an if/else statement, if the boolean expression is false, the statement or block following the (if or else)______ is executed.else
What would be the value of r after the following statements are executed? double r; String s = "XY"; switch (s) { case "X": r = 0.01; break; case "XY": r = 0.03; break; case "XX": r = 0.05; break; default: r = 0.00; }0.03
________ evaluation works like this: If the expression on the left side of the && operator is false, the expression the right side will not be checked.Short-circuit
Enclosing a group of statements inside a set of braces creates a: ______ of statements.Block
Multiple alternative decision structure is a ______ statement.SWITCH
If str1 and str2 are both Strings, which of the following will correctly test to determine whether str1 is less than str2? (1) (str1 < str2) (2) (str1.equals(str2) < 0) (3) (str1.compareTo(str2) < 0)(3)
The ________ statement is used to make simple decisions in Java.if
correctly tests the char variable chr to determine whether it is not equal to the character B? if (_______)(char != 'B')
A loop that executes as long as a particular condition exists is called a(n): _________ loopConditional
Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops shows the correct way to read data from the file until the end of the file is reached? while (___________) { }(inputFile.hasNext())
Before entering a loop to compute a running total, the program should first do this: ________ the TOTAL value, usually _____.initialize, 0
If a loop does not contain within itself a way to terminate, it is called a(n): _____ loopInfinite
This type of loop is ideal in situations where the exact number of iterations is known: _______ loopfor
_____ validation is the process of inspecting data given to the program by the user and determining if it is valid.input
What will be the value of x after the following code is executed? int x = 10; for (int y = 5; y < 20; y += 5) x += y: x = ___40
This variable controls the number of times that the loop iterates: ____ ______ variable.loop control
This is a sum of numbers that accumulates with each iteration of a loop: _______ totalRunning
In all but rare cases, loops must contain within themselves: a way to _____.terminate
In the for loop, the control variable cannot be initialized to a constant value and tested against a constant value. TRUE OR FALSE?FALSE
When you open a file with the PrintWriter class, the class can potentially throw an IOException. TRUE OR FALSE?TRUE
When you pass the name of a file to the PrintWriter constructor, and the file already exists, it will be erased and a new empty file with the same name will be created. TRUE OR FALSE?TRUE
The while loop has two important parts: (1) a boolean expression that is tested for a true or false value, and (2) a statement or block of statements that is repeated as long as the expression is true. TRUE OR FALSE?TRUE
In a for statement, the control variable can only be incremented. TRUE OR FALSE?FALSE
Java provides a set of simple unary operators designed just for incrementing and decrementing variables. TRUE OR FALSE?TRUE
A special variable that holds a value being passed into a method is called what?Parameter
A value-returning method must specify this as its return type in the method header: ____ _____ data type.Any valid
f method A calls method B, and method B calls method C, and method C calls method D, when method D finishes, what happens? Control is returned to method __.C
If you attempt to use a local variable before it has been given a value: a _____ ______ will occur.compiler error
In the following code, Integer.parseInt(str), is an example of ________. int num; string str = "555"; num = Integer.parseInt(str) + 5; a _______-______ methodvalue-returning
The process of breaking a problem down into smaller pieces is sometimes called: ______ and ______Divide and conquer.
This type of method performs a task and sends a value back to the code that called: value-______ methodreturning
Values that are sent into a method are called ________.arguments
When a parameter value is changed within the body of a method: the change has (NO EFFECT or AN EFFECT) _______ on the associated argument value when the method returns.NO EFFECT
When an object, such as a String, is passed as an argument, it is NOT a reference to the object that has passed: TRUE OR FALSE?FALSE, it IS a reference to the object that has passed.
This type of method performs a task and then terminates: _____void
When writing the documentation comments for a method, you can provide a description of each parameter by using a: _______ tag@param
When you pass an argument to a method, be sure that the argument's data type is compatible with: The ______ ______'s data type.parameter variable
In the method header, public static doSomething(), what does public mean? it can be accessed where?It can be accessed outside the class it is defined.
A value-returning method must have at least one _______ statementreturn
When invoking a method, you must ensure that the arguments agree with the parameters in ______, _______ and _____.number, order and type
In order to execute a _____ must be called by another _____ .method, method
This kind of method receives input data specifically supplied to that method only: methods ______ _______ at the definition.declaring parameters
kb.nextInt(); is an example of a __________ method.value-returning
Classes in java describe _____ .objects
The type of Object is: a. determined by the Virtual Machine b. the ID of its defining class c. can be any primitive type d. objects do not have typesb. the ID of its defining class
The method having the header: public int print (double num, double other) must return _______.an integer value; public INT print (double num, double other)
An object in Java can: a. store data of primitive type b. store references to other objects c. perform operations d. all of the aboved. all of the above
A commonly used class in Java: _____ classPublic
Data stored in an object are called _____.fields
a for
studybud

Your Answer

Surround your text in *italics* or **bold**, to write a math equation use, for example, $x^2+2x+1=0$ or $$\beta^2-1=0$$

Use LaTeX to type formulas and markdown to format text. See example.

Sign up or Log in

  • Answer the question above my logging into the following networks
Sign in
Sign in
Sign in

Post as a guest

  • Your email will not be shared or posted anywhere on our site
  •  

Stats
Views: 16
Asked: 2 years ago

Related