Question
1. The __________ operator can be used to ensure that two conditions are both true before choosing a certain path of execution. 2. The __________
1. The __________ operator can be used to ensure that two conditions are both true before choosing a certain path of execution.
2. The __________ operator can be used to ensure a certain path of execution is chosen if at least one of two conditions are true.
3. The __________ operator can be used to ensure exactly one of two conditions is true before choosing a certain path of execution.
4. Compare and contrast the break and continue statements.
5. Discuss a situation where it would be more appropriate to use a dowhile statement than a while statement. Explain why.
6. Write code that performs exactly the same actions as the code below, using a switch statement. if (x == 1) { System.out.println("one"); else { if (x == 10) { System.out.println("ten"); } System.out.println("the value is not one"); } (10 points)
7. In mathematics, the factorial of a positive integer n (written as n! and pronounced "n factorial") is the product of the positive integers from 1 to n. Write an application in a class named Factorial that calculates and displays the factorial of all integers 1 through 20, using the long data type. Upload the Factorial.java source file to Blackboard. (10 points)
8. The __________ keyword causes a method or variable to be applied to the entire class, instead of to individual objects of the class.
9. The __________ keyword causes a variable to maintain a constant, unchanging value.
10. The __________ class contains values and methods that are useful for mathematical operations.
11. To which types can a variable of type short be automatically promoted in a method call?
12. Which primitive types cannot be automatically promoted?
13. The process of creating multiple methods with the same name in the same class is called __________.
14. The __________ keyword is used to create a special variable type with a limited set of potential values.
15. Explain the problem with the Greeting class below and how it can be fixed. public class Greeting { private String text; public Greeting(String text) { this.text = text; } public static String getText() { return text; } } (10 points)
16. Assuming you have declared a variable n of type int and a variable b of type byte, write a statement that assigns the value of n to the variable b. What is the drawback of doing this? (10 points)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started