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
Create a free account and access millions of resources
Similar Resources on Wayground
16 questions
Variables and Data Types Knowledge Check

Quiz
•
9th - 12th Grade
6 questions
Topic 6.1 Video 2

Quiz
•
11th Grade
15 questions
2D Arrays

Quiz
•
9th - 12th Grade
15 questions
Python Programming

Quiz
•
5th Grade - University
16 questions
Python - Variables and Input

Quiz
•
1st - 10th Grade
10 questions
Arrays

Quiz
•
10th - 12th Grade
16 questions
Python basics

Quiz
•
9th - 12th Grade
10 questions
SLR 9 - Advanced Programming Techniques - Part Two

Quiz
•
10th Grade
Popular Resources on Wayground
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
20 questions
PBIS-HGMS

Quiz
•
6th - 8th Grade
10 questions
"LAST STOP ON MARKET STREET" Vocabulary Quiz

Quiz
•
3rd Grade
19 questions
Fractions to Decimals and Decimals to Fractions

Quiz
•
6th Grade
16 questions
Logic and Venn Diagrams

Quiz
•
12th Grade
15 questions
Compare and Order Decimals

Quiz
•
4th - 5th Grade
20 questions
Simplifying Fractions

Quiz
•
6th Grade
20 questions
Multiplication facts 1-12

Quiz
•
2nd - 3rd Grade