Casting in Java

Casting in Java

9th - 12th Grade

11 Qs

quiz-placeholder

Similar activities

19W Final Exam - PLTW

19W Final Exam - PLTW

9th - 12th Grade

15 Qs

Python Data Types

Python Data Types

9th - 12th Grade

10 Qs

Arrays

Arrays

10th - 12th Grade

10 Qs

Java Math

Java Math

9th - 12th Grade

15 Qs

29W Quiz 1 - PLTW

29W Quiz 1 - PLTW

8th - 12th Grade

15 Qs

CS A U1 Review

CS A U1 Review

12th Grade

8 Qs

AP CS A Unit 7 Quiz PRACTICE

AP CS A Unit 7 Quiz PRACTICE

9th - 12th Grade

10 Qs

Python Beginners Week 6

Python Beginners Week 6

3rd - 12th Grade

13 Qs

Casting in Java

Casting in Java

Assessment

Quiz

Computers

9th - 12th Grade

Hard

Created by

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?

7.0
7.5
8.0
15.0

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?

0.5
10.5
10
0

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?

1.0
7.0
0.0
None of the above

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?

10 3.0 3.3333333333333335
10 3.0 3.0
10 3.0 3.33
10 3.0 3.3

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?