CPS 180 Exam 1 Questions With Complete Solutions
What is the output of the following code: int x = 3; int y = 3; int z = 3/6; Sln(z); correct answer: 0, to fix this z would have to be a double/float and be defined as 3.0/6.0 Create a constant to hold the number of cars in a lot correct answer: final int NUM_CARS; How do you name constants? correct answer: Put "final" before the variable type, and name the variable in all caps with words separated by underscores. double correct answer: largest primitive variable type, holds decimals String correct answer: creates an object containing words, can be manipulated since it is an object int correct answer: primitive variable type that holds only whole numbers how do you create a scanner object? correct answer: Scanner //name of the scanner here// = new Scanner(S); Int(); correct answer: returns input as an int Double(); correct answer
Document information
- Uploaded on
- May 19, 2023
- Number of pages
- 2
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers