Chapter 2 Quiz

docx

School

Kennesaw State University *

*We aren’t endorsed by this school

Course

104

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

7

Uploaded by kirahmartin

Report
CHAPTER 2 QUIZ 1. A boolean variable can hold any character. True False 2. Which assignment is correct in Java? char aChar = '*'; Two of these are correct char aChar = "W"; char aChar = 5.5; 3. The assignment operator in Java is == True False 4. When data cannot be changed after a class is compiled, the data is ____________. constant volatile mutable variable 5. According to the rules of operator precedence, when division occurs in the same arithmetic statement as ____________, the division operation always takes place first. multiplication remainder subtraction Answers a and b are correct.
6. The remainder operator ____________. provides the quotient of integer division is represented by % is represented by a forward slash must follow a division operation 7. Which assignment is correct in Java? double money = 12.0; double money = 12; double money = 12.0d; all of the above 8. The equal to relational operator is ____________. "!=" "!!" "==" "=" 9. If you attempt to add a float, an int, and a byte, the result will be a(n) ____________. error message int float byte 10. In Java, what is the value of 3 + 7 * 4 + 2?
21 48 42 33 11. Which of the following data types can store the value 0 using the least amount of memory? int short byte long 12. You use a type cast to explicitly override an implicit type. True False 13. Which Java statement produces w on one line and xyz on the next line? System.out.println("w\nx\ny\nz"); System.out.println("w" + "xyz"); System.out.println("wxyz"); System.out.println("w\nxyz"); 14. Which assignment is correct in Java? double value = 2.12; int value = (float) 4.5;
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
float value = 4 (double); char value = 5c; 15. The value 137.68 can be held by a variable of type float . True False 16. Assuming you have declared shoeSize to be a variable of type int , which of the following is a valid assignment statement in Java? shoeSize = 9.5; shoeSize = "nine"; shoeSize = 9; Two of the above are valid. 17. When you perform arithmetic with values of diverse types, Java ____________. issues an error message requires you to explicitly convert the values to a unifying type implicitly converts the values to the type of the first operand implicitly converts the values to a unifying type 18. An escape sequence always begins with a(n) ____________. forward slash equal sign e backslash
19. Which of the following is not a primitive data type in Java? sector byte int Boolean 20. Which of the following elements is not required in a variable declaration? an assigned value a semicolon a type an identifier
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help