Exam 6: More Conditionals and Loops
Exam 1: Introduction64 Questions
Exam 2: Data and Expressions67 Questions
Exam 3: Using Classes and Objects49 Questions
Exam 4: Writing Classes53 Questions
Exam 5: Conditionals and Loops38 Questions
Exam 6: More Conditionals and Loops35 Questions
Exam 7: Object-Oriented Design44 Questions
Exam 8: Arrays45 Questions
Exam 9: Inheritance49 Questions
Exam 10: Polymorphism40 Questions
Exam 11: Exceptions39 Questions
Exam 12: Recursion55 Questions
Exam 13: Collections60 Questions
Select questions type
How can the following statement be rewritten using a conditional operator? if(x <0) y = x;
Else y = 0;
(Multiple Choice)
5.0/5
(26)
Write a declaration that initializes an int variable named num1 to 100 if the boolean variable score is true and to 50 otherwise, using the conditional operator.
(Short Answer)
4.9/5
(42)
Rewrite the following nested if-else statements using an equivalent switch statement.
if (letter == 'A' || letter == 'a')
System.out.println("Excellent");
else if (letter == 'B' || letter == 'b')
System.out.println("You can do better");
else if (letter == 'C' || letter == 'c')
System.out.println("Try harder");
else if (letter == 'D' || letter == 'd')
System.out.println("Try much harder");
else System.out.println("Try another major! ");
(Essay)
4.9/5
(43)
You might choose to use a switch statement instead of nested if-else statements if
(Multiple Choice)
4.9/5
(38)
Given that s is a String, what does the following loop do? for(int j = s.length(); j > 0; j--)
System.out.print;
(Multiple Choice)
4.8/5
(33)
Describe a situation where you should use a do loop and a situation where you should use a while loop.
(Essay)
4.8/5
(42)
It is possible to convert any type of loop (while, do, for) into any other.
(True/False)
4.8/5
(41)
Given the following tax table information, write Java code to assign the double taxRate appropriately, given the double pay. Select the selection statement (if, if-else, switch) that makes the most sense.
If pay is more than 100,000, tax rate is 40%
If pay is more than 60,000 and less than or equal to 100,000, tax rate is 30%
If pay is more than 30,000 and less than or equal to 60,000, tax rate is 20%
If pay is more than 15,000 and less than or equal to 30,000, tax rate is 10%
If pay is more than 5,000 and less than or equal to 15,000, tax rate is 5%
If pay is less than or equal to 5,000, tax rate is 0%
(Essay)
4.8/5
(36)
Write the code to display an ImageView named the_view at half its original size.
(Essay)
4.7/5
(37)
Rewrite the following if-else statement using a conditional operator.
if (x > y) z = x; else z = y;
(Short Answer)
4.9/5
(50)
Given the following code, where x = 0, what is the resulting value of x after the for loop terminates? for(int i = 0; i < 5; i++)
X += i;
(Multiple Choice)
5.0/5
(29)
Showing 21 - 35 of 35
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)