CJCoding With Joseph
15per day
← Back to Question List
Java Code Walkthrough #30

Integer Division Then Cast

mediumOperators

📄 Code

Read carefully — what does this print?
1public class Main {
2 public static void main(String[] args) {
3 int a = 5;
4 int b = 2;
5 
6 double x = a / b;
7 double y = (double) a / b;
8 
9 System.out.println(x);
10 System.out.println(y);
11 }
12}

🎯 Your Answer