Which of the following expressions in Java is equal to 1?
7 % 3
What is printed when the following code has been executed? int x = 13; int y = 6; System.out.println((2 * x + y) % x);
6
Consider the following program which is intended to get the amount of time (in seconds) it took someone to do one of their chores and then converts it to minutes and seconds. Scanner scan = new Scanner(System.in);int m = 0; int s; System.out.print("How many seconds did it take you to do one of your chores? "); s = scan.nextInt(); /* missing code */ System.out.println("It took you " + m + " minutes and " + s + " seconds."); Which of the following could replace the missing code so that it all works as intended?
m = s / 60; s = s % 60;
Which line of code properly casts a double to an integer?
int n = (int) 6.71;
What is the output when the following code is executed? int a = 93; double x = 89.86732; System.out.println((int) x);
89
What is the output when the following code is executed? int a = 93; double x = 89.86732; System.out.println(a / 3);
31
What is one reason we would use numeric casts in Java?
There is a chance that you lose data when you convert from a larger data type to a smaller data type.
Executing which of the following lines of code would cause widening conversions to take place?
double a = 19 / 7; double a = (double) 23 / 6;
What is the output when the following code is executed? int a = 93; double x = 89.86732; System.out.println((double) a);
93.0
What is the value of num2 when the following code is executed? double num = 34; int num2 = (int) (34/3);
11