Exam 6: Looping
Exam 1: Creating Java Programs61 Questions
Exam 2: Using Data67 Questions
Exam 3: Using Methods Classes and Objects66 Questions
Exam 4: More Object Concepts66 Questions
Exam 5: Making Decisions66 Questions
Exam 6: Looping66 Questions
Exam 7: Characters Strings and the Stringbuilder68 Questions
Exam 8: Arrays66 Questions
Exam 9: Advanced Array Concepts66 Questions
Exam 10: Introduction to Inheritance66 Questions
Exam 11: Advanced Inheritance Concepts66 Questions
Exam 12: Exception Handling66 Questions
Exam 13: File Input and Output66 Questions
Exam 14: Introduction to Swing Components66 Questions
Exam 15: Advanced Gui Topics66 Questions
Exam 16: Graphics66 Questions
Select questions type
Making a comparison to 0 is slower than making a comparison to any other value.
(True/False)
4.7/5
(35)
Many seasoned programmers start counter values at 1 because they are used to doing so when working with arrays.
(True/False)
4.9/5
(43)
What are some unconventional uses of the three sections inside the parentheses of a for loop? Show at least three examples using code.
(Essay)
4.8/5
(37)
Which of the following is NOT a valid method to increase a variable named score by 1?
(Multiple Choice)
4.8/5
(34)
The ____________________ loop is the posttest loop used in Java.
(Short Answer)
4.8/5
(42)
public class IncrDemo
{
public static void main(String[] args)
{
int myVal, yourVal;
myVal = 10;
System.out.println("My initial value is " + myVal);
yourVal = ++myVal;
System.out.println("My new value is " + myVal);
System.out.println("Your value is " + yourVal):
}
}
Using the above code, describe how the three println output commands will appear. Explain the values stored in the variables during code execution.
(Essay)
4.8/5
(45)
Use a(n) ____ loop to execute a body of statements continually as long as the Boolean expression that controls entry into the loop continues to be true .
(Multiple Choice)
4.7/5
(33)
What are the three sections inside the parentheses of a for loop typically used for?
(Essay)
4.9/5
(39)
Why would a programmer use curly braces in the body of a do…while loop?
(Essay)
4.8/5
(30)
public class DoWhileExample
{
public static void main(String[] args)
{
int currentValue;
____
____
____
____
____
}
}
Complete the code above by writing a do…while posttest loop that will output the value of the variable currentValue in a println statement. After the output statement, add a decrement statement to decrease the value of currentValue by 1. Continue the loop until currentValue is equal to 0.
(Essay)
4.9/5
(34)
When creating a for loop, which statement will correctly initialize more than one variable?
(Multiple Choice)
4.9/5
(31)
When loops are nested, each pair contains a(n) ____________________ loop and an outer loop.
(Short Answer)
4.9/5
(40)
Programmers rarely use indefinite loops when validating input data.
(True/False)
4.8/5
(39)
You use a unary minus sign preceding a value to make the value ____.
(Multiple Choice)
4.9/5
(44)
Provide a code example of a pretest loop and an example of a posttest loop.
(Essay)
4.7/5
(41)
Create an indefinite while loop that will validate that the loop control variable named userNum is less than the constant MAXVALUE . While true, create a println statement to output "Please enter a higher value". Get user input of another value for userNum after each println statement. Once MAXVALUE is reached, create a final println statement that will output "Max value reached".
(Essay)
4.9/5
(39)
Showing 21 - 40 of 66
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)