What is the output of the following code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

What is the output of the following code?

package javaapplication; public static void main(String[ ] args) { String name = "David"; int age = 25; int y = 12; int result = age / y; int num1 = 8; int num2 = 4; num2 += num1; double score = 12.3; char you = 'z'; System.out.println(num2); } }

3rd Oct 2019, 5:31 PM
Jibrilla Abdul-Razak
Jibrilla Abdul-Razak - avatar
4 Answers
+ 2
You're only printing out num2 += num1 which is 4+8
3rd Oct 2019, 6:42 PM
HNNX 🐿
HNNX 🐿 - avatar
+ 1
12
3rd Oct 2019, 6:21 PM
id001x
id001x - avatar
+ 1
Jibrilla Abdul-Razak You can check in Sololearn playground.
3rd Oct 2019, 8:58 PM
A͢J
A͢J - avatar
0
Ok...thanks
4th Oct 2019, 3:54 PM
Jibrilla Abdul-Razak
Jibrilla Abdul-Razak - avatar