98-388 Exam QuestionsBrowse all questions from this exam

98-388 Exam - Question 22


You need to evaluate the following code segment:

Exam 98-388 Question 22

What happens when the code segment is run?

Show Answer
Correct Answer: C

When the code segment is run, the double value 2.667 is cast to an integer. In Java, casting a double to an integer truncates the decimal part and keeps the integer part. Therefore, iNum will have a value of 2 after the cast.

Discussion

3 comments
Sign in to comment
KaleIsGross
Apr 7, 2021

Answer is C

Abdullahsawaftah
Jul 4, 2021

true,i checked by running the code myself.====> 2 is the answer.

Abhitera
Feb 10, 2021

Answer shoud be 3 as it does round of

benblakemore
Feb 12, 2021

Incorrect, casting to int ignores trailing decimal values and results in 2. I checked by running the code myself.

Abhitera
Feb 12, 2021

Ya true brother...u r right

Abhitera
Feb 12, 2021

Ya true brother...u r right