- Can different types of numeric values be used together in computation?
Bisa karena ada tipe data numerik yang digunakan pada saat tertentu seperti perhitungan damage dari sebuah game dan juga double didalam sebuah perhitungan bunga dan saldo bank.
- Assume that int a = 1 and double d = 1.0 and that each expression is independent. What are the results of the following expressions?
- a = 46 % 9 + 4 * 4 – 2
- A = 45 + 43 % 5 * (23 * 3 % 2)
- a %= 3 / a + 3
- d += 1.5 * 3 + (++a)
- Are the following statements correct? If so, show the output.
- System.out.println(“25 / 4 is “ + 25 / 4);
Benar. Hasilnya adalah 6. - System.out.println(“25 / 4.0 is “ + 25 / 4.0);
Benar. Hasilnya adalah 6.25. - System.out.println(“3 * 2 / 4 is “ + 3 * 2 / 4);
Benar. Hasilnya adalah 1. - System.out.println(“3.0 * 2 / 4 is “ + 3.0 * 2 / 4);
Benar. Hasilnya adalah 1.5.