Consider the following code segment.
int a = 15;
double b = (double) a / 2.0;
System.out.println(b);
What is printed as a result of executing the code segment?
Casting in Java
Quiz
•
Computers
•
9th - 12th Grade
•
Hard
Patrick Bryar
Used 2+ times
FREE Resource
11 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment.
int a = 15;
double b = (double) a / 2.0;
System.out.println(b);
What is printed as a result of executing the code segment?
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment.
int x = 5;
double y = (double) (x * 2);
System.out.print(x + " " + y);
What is printed as a result of executing the code segment?
5 10.0
5 10
10 5.0
10 5
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment.
double num1 = 10.5;
int num2 = (int) num1;
double result = num1 - num2;
System.out.println(result);
What is printed as a result of executing the code segment?
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment.
int m = 8;
double n = (double) (m + 3) / 2;
System.out.print(m + " " + n);
What is printed as a result of executing the code segment?
8 5.5
8 6.0
8 5.0
11 5.5
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment.
double x = 7.0;
int y = (int) x;
double z = x / y;
System.out.println(z);
What is printed as a result of executing the code segment?
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment.
int a = 10;
double b = 3.0;
double c = (double) a / b;
System.out.print(a + " " + b + " " + c);
What is printed as a result of executing the code segment?
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment.
int x = 6;
double y = (double) (x / 2);
System.out.println(x + " " + y);
What is printed as a result of executing the code segment?
6 3.0
6 3
3 3.0
3 3
10 questions
AP CS A Unit 7 Quiz PRACTICE
Quiz
•
9th - 12th Grade
12 questions
Java Strings
Quiz
•
9th - 12th Grade
10 questions
Unit 6
Quiz
•
12th Grade
16 questions
Arithmetic Types Declare Initialize Relation Logical Ops
Quiz
•
9th Grade - University
10 questions
AP CSP Review
Quiz
•
9th - 12th Grade
10 questions
Python Data Types
Quiz
•
9th - 12th Grade
16 questions
Python basics
Quiz
•
9th - 12th Grade
10 questions
SLR 9 - Advanced Programming Techniques - Part Two
Quiz
•
10th Grade
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
20 questions
Taxes
Quiz
•
9th - 12th Grade
17 questions
Parts of Speech
Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression
Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing
Quiz
•
9th - 12th Grade
10 questions
Identifying equations
Quiz
•
KG - University