Casting in Java

Quiz
•
Computers
•
9th - 12th Grade
•
Medium
Patrick Bryar
Used 4+ 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
10 questions
AP CS A Unit 7 Quiz PRACTICE

Quiz
•
9th - 12th Grade
15 questions
if-else-if and Logical Operators

Quiz
•
9th - 12th Grade
10 questions
AP CS A Unit 6 Quiz PRACTICE

Quiz
•
9th - 12th Grade
12 questions
Java Strings

Quiz
•
9th - 12th Grade
10 questions
C#

Quiz
•
11th Grade
10 questions
Variables and Data Types

Quiz
•
10th - 12th Grade
8 questions
Topics 7 & 8 - Static Methods/Variables and Null Keyword

Quiz
•
12th Grade
14 questions
C ++ For Loop

Quiz
•
9th - 12th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
Proper Keyboarding Techniques

Interactive video
•
6th - 10th Grade
14 questions
Inputs and Outputs: Computer Science Intro

Lesson
•
5th - 9th Grade
10 questions
Understanding Computers: Hardware, Software, and Operating Systems

Interactive video
•
7th - 12th Grade
29 questions
AP CSP Unit 2 Review (Code.org)

Quiz
•
10th - 12th Grade