Multiple choice

What will be the output of the following code?public class Short { public static void main(String[] args) { int a,b,c; a=1; b=2; c=a+b; System.out.println("C="+c); } }

  1. Run time error

  2. Compile time error

  3. C=3

  4. Garbage value

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The code performs simple integer addition: a=1, b=2, so c=a+b equals 3. The println statement concatenates "C=" with the value of c (3), producing "C=3" as output. There are no compilation or runtime errors.