|
|
Ch 3 Questions #2 Conditional Statements
#2 |
|
|
|
1. How would you compare two strings? Can you use the equality operator? 2. Is it a good idea in a program to compare floating point values (floats or doubles) for equality? Explain 3. What are the three ways to increment a variable? 4. How do you decrement a variable? 5. What does the operator "&&" mean? 6. Given the following: if
( (x == 7) || (x == 10) what values would x have to equal to have the next line of code executed? 7. Given the following: if
( (x < 10) && (x != 5) System.out.println ("Go home"); else System.out.println ("Stay here"); what would be printed for values of x equal to one through ten? 8. What expression could be placed into an if statement so that all values would be between 0 and 100 inclusive? 9. Can you mix different data type types in a conditional statement? Explain. 10. How do you compare strings for equality? if
(x = 7) |
|