Project Stem CSA Unit 1 Exam, Exams of Nursing

Project Stem CSA Unit 1 Exam passed

Typology: Exams

2024/2025

Available from 07/07/2025

studyclass
studyclass 🇺🇸

1

(1)

28K documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Project Stem CSA Unit 1 Exam
double val = scan.nextDouble(); - correct answer ✔✔Assuming that scan is a properly initialized Scanner
variable, which of the following correctly inputs a double?
double val = nextDouble();
double val = scan.nextValue();
double val = scan.nextInt();
double val = scan.nextLine();
double val = scan.nextDouble();
-4 - correct answer ✔✔Consider the following code:
int x = -5;x++;System.out.println(x);
What is output?
-3
5
-7
-4
7
boolean - correct answer ✔✔Which of the following data types would be most appropriate to use when
recording the answer to a yes or no question?
String
int
boolean
None of the above types could be used
double
String - correct answer ✔✔Which of the following is not a primitive data type?
pf3
pf4
pf5

Partial preview of the text

Download Project Stem CSA Unit 1 Exam and more Exams Nursing in PDF only on Docsity!

Project Stem CSA Unit 1 Exam

double val = scan.nextDouble(); - correct answer ✔✔Assuming that scan is a properly initialized Scanner variable, which of the following correctly inputs a double? double val = nextDouble(); double val = scan.nextValue(); double val = scan.nextInt(); double val = scan.nextLine(); double val = scan.nextDouble(); -4 - correct answer ✔✔Consider the following code: int x = -5;x++;System.out.println(x); What is output?

5

7 boolean - correct answer ✔✔Which of the following data types would be most appropriate to use when recording the answer to a yes or no question? String int boolean None of the above types could be used double String - correct answer ✔✔Which of the following is not a primitive data type?

int String boolean double 5 - correct answer ✔✔What is output by the following code? int a = 11;System.out.println(a / 2); 6 5

11 11

nameOne - correct answer ✔✔Which of the following is a legal variable name in Java? nameOne int 1name name. the name 10 - correct answer ✔✔What is (19 % 7) * 2? 6 21 14 10 7 double A;

3 - correct answer ✔✔Consider the following code: int x = 10;int y = 3;System.out.println((x * y) / x ); What is output? 10 3 6 9 13 no, nothing - correct answer ✔✔Consider the following variable declaration: double number = 23; Does a cast need to be added so this code will compile and run successfully? ______. If so, what should be typed for this cast? _______ yes, (String) yes, (int) no, nothing yes, (decimal) yes, (double) All choices are correct - correct answer ✔✔For which of the following would modular division be useful? identifying the digits of an integer money calculations using dollars and cents time calculations using days and weeks testing whether numbers are even or odd All choices are correct

It needs a cast so that the decimal portion will be shown. - correct answer ✔✔The following code is intended to input two integers and print the average. What is a potential problem with the code as written? System.out.println("Please enter two integers: ");int a = scan.nextInt();int b = scan.nextInt();System.out.println("The average is: " + (a + b) / 2); No correction needed, the code will work as written. It needs a cast so that the decimal portion will be shown. The parentheses are not needed and will cause a mathematical error. There is no division needed. It should use scan.nextDouble instead of scan.nextInt. 3 - correct answer ✔✔What is output by the following code? int num = 0; num++; num++; num++; num++; num--; num++; num--; num--; num++; System.out.println(num); 1 3 5 0 2

int p = (double) 43.92; No changes, the code is fine. int p = int (43.92); int p = double (43.92); System.out.print(x / 10 % 10); - correct answer ✔✔Which of the following will print the tens column of an integer stored in x? None of the above System.out.print(x / 10 % 10); System.out.print(10 % x); System.out.print(x % 10 / 10); System.out.print(x / 10);