Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
hard Solved by 1 students

Casting Arithmetic Result

Mark
< Prev
Next >

A floating-point value is truncated to an integer before being involved in a division operation with another integer.

What is printed when the following Java program is compiled and run?

public class QuestionTrace {

    public static void main(String[] args) {
        double val1 = 8.7;
        int val2 = 3;
        double result = (int) val1 / val2;
        System.out.println(result);
    }
}
A

2.0

B

2.6666666666666665

C

2.9

D

3.0

Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Instagram: @_apfive_|Privacy Policy|