- 2

What Is The answer of This one

What is the result of the following code? int x = 15; int y = 4; int result = x / y; System.out.println(result);

16th Jun 2017, 7:17 PM
Malangi
Malangi - avatar
12 Answers
+ 4
@Ulisses Cruz Yes, I was explaining how it works.
16th Jun 2017, 8:00 PM
ChaoticDawg
ChaoticDawg - avatar
+ 4
Answer is 3 because you are using 'int' data type which means you are dividing whole numbers(numbers without decimal places) and your answer will also be a whole number. So the numbers after decimal will be ignored in this case, so answer would be 3.
20th Jun 2017, 3:42 AM
blACk sh4d0w
blACk sh4d0w - avatar
+ 3
3. Wouldn't have running that code been better than asking us?
16th Jun 2017, 7:28 PM
LordHill
LordHill - avatar
+ 3
With integer division everything past the decimal is truncated. 15/4 = 3.75 The .75 is cut off leaving 3 as the answer.
16th Jun 2017, 7:37 PM
ChaoticDawg
ChaoticDawg - avatar
0
3
13th Dec 2021, 5:27 AM
M.H.F Zahra
0
12th Feb 2022, 1:41 AM
vina febriabti
0
15/6 Table 6*2=12 (15-12)=3 3 is remainder
20th May 2022, 11:01 PM
Abdul Qadir Paracha
Abdul Qadir Paracha - avatar
0
15/4 Table 4*3=12 (15-12)=3 3 remainder
20th May 2022, 11:04 PM
Abdul Qadir Paracha
Abdul Qadir Paracha - avatar
0
3
27th Aug 2022, 8:47 PM
Ehab Gamal
0
+3
22nd Feb 2023, 8:43 PM
Scott Krassin
Scott Krassin - avatar
0
Translate course What is the result of the following code? int x = 15; int y = 4; int result = x / y; System.out.println(result); Answer is 3
7th Sep 2024, 9:14 AM
Budhabhushan Waghmare
Budhabhushan Waghmare - avatar
0
int x = 8, y = 5; int result = x % y; Answer is 3
7th Sep 2024, 9:16 AM
Budhabhushan Waghmare
Budhabhushan Waghmare - avatar