Casting in Java

Casting in Java

9th - 12th Grade

11 Qs

quiz-placeholder

Similar activities

Unit 6

Unit 6

12th Grade

10 Qs

MP3 Arrays Test

MP3 Arrays Test

11th Grade

15 Qs

AP CSA Unit 1 & 2 Review

AP CSA Unit 1 & 2 Review

9th - 12th Grade

10 Qs

Arithmetic Types Declare Initialize Relation Logical Ops

Arithmetic Types Declare Initialize Relation Logical Ops

9th Grade - University

16 Qs

AP CSP Review

AP CSP Review

9th - 12th Grade

10 Qs

AP Java 9-15-2023 (just functions1)

AP Java 9-15-2023 (just functions1)

9th - 12th Grade

10 Qs

NISD CS AP Exam Prep

NISD CS AP Exam Prep

10th - 12th Grade

12 Qs

Java (Identifiers, data types, operators and expressions)

Java (Identifiers, data types, operators and expressions)

12th Grade

16 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?