Exam 5: Making Decisions
Exam 1: Creating Java Programs68 Questions
Exam 2: Using Data74 Questions
Exam 3: Using Methods, Classes, and Objects68 Questions
Exam 4: More Object Concepts67 Questions
Exam 5: Making Decisions70 Questions
Exam 6: Looping72 Questions
Exam 7: Characters, Strings, and the Stringbuilder73 Questions
Exam 8: Arrays74 Questions
Exam 9: Advanced Array Concepts74 Questions
Exam 10: Introduction to Inheritance70 Questions
Exam 11: Advanced Inheritance Concepts70 Questions
Exam 12: Exception Handling65 Questions
Exam 13: File Input and Output74 Questions
Exam 14: Introduction to Swing Components74 Questions
Exam 15: Advanced Gui Topics69 Questions
Exam 16: Graphics74 Questions
Exam 17: Applets, Images, and Sound72 Questions
Select questions type
Explain the use of the NOT operator.
Free
(Essay)
4.7/5
(84)
Correct Answer:
You use the NOT operator, which is written as the exclamation point ( ! ), to negate the result of any Boolean expression. Any expression that evaluates as True becomes False when preceded by the NOT operator; and accordingly, any False expression preceded by the NOT operator becomes True.
Why would a programmer need to use a range check? Give an example.
Free
(Essay)
4.8/5
(73)
Correct Answer:
A range check is a series of statements that determine within which of a set of ranges a value falls. Consider a situation in which salespeople can receive one of three possible commission rates based on their sales.
When an expression containing a ____ is part of an if statement, the assignment is illegal.
Free
(Multiple Choice)
5.0/5
(78)
Correct Answer:
A
Explain the difference between a single-alternative if structure and a dual-alternative if structure. When would it be necessary to use a dual-alternative if structure?
(Essay)
4.9/5
(82)
Match each term with the correct statement below.
-Used in the OR operator
(Multiple Choice)
4.8/5
(83)
Range checking and the switch statement are tools programmers can use for effective decision making.
(True/False)
4.9/5
(92)
An alternative to using a Boolean expression, such as quizScore == 10, is to store the Boolean expression's value in a Boolean variable. How could you express this in Java?
(Essay)
4.7/5
(74)
Write a nested if statement that will check if the variable qtySold is greater than the QTY_QUOTA constant. If true, evaluate a second expression that will check if the variable totalSales is greater than the constant SALES_QUOTA. If the second expression is also true, create an assignment statement that will assign the constant BONUSAMT to the variable bonus. After BONUSAMT is assigned, the if structure ends.
(Essay)
4.7/5
(77)
Both & and | are valid Java operators, but they operate on ____________________ rather than making comparisons in logical conditions as && and || do.
(Short Answer)
5.0/5
(84)
A ____ consists of written steps in diagram form, as a series of shapes connected by arrows.
(Multiple Choice)
4.8/5
(80)
if (quotaAmt > 100 || sales > 100 && productCode == "C") bonusAmt = 50;
When the above code is executed, which operator is evaluated first?
(Multiple Choice)
5.0/5
(81)
if(qtySold > QUOTA)
bonusPay = 50;
totalPay = regPay + bonusPay;
System.out.println("Your totalPay amount is " + totalPay);
Why is the above code incorrect? What would be required to make the code execute correctly?
(Essay)
4.9/5
(74)
When you block statements, you must remember that any ____ you declare within a block is local to that block.
(Multiple Choice)
4.7/5
(86)
A(n) ____________________ structure is one that involves choosing between alternative courses of action based on some value within a program.
(Short Answer)
4.8/5
(84)
if(firstValue == secondValue)
{
int total = firstValue + secondVaue;
System.out.println("The values are equal");
}
System.out.println("The total is " + total);
Why will the above println() statement cause an error?
(Essay)
4.9/5
(79)
Match each term with the correct statement below.
-Two possible courses of action
(Multiple Choice)
4.8/5
(83)
When you execute an if…else statement, only one of the resulting actions takes place depending on the evaluation of the ____ following the if.
(Multiple Choice)
4.8/5
(85)
Create an if…else statement that will check if the maxValue variable is equal to 100. If true, create a println statement that will output "Max reached". If false, create a println statement to output "Keep trying".
(Essay)
4.9/5
(58)
Match each term with the correct statement below.
-The logical NOT operator
(Multiple Choice)
4.9/5
(92)
Showing 1 - 20 of 70
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)