Multiple choice technology programming languages


a = 10;         
var b = 20;         
var c = a + b;          
alert(c);   

  1. error

  2. 1020

  3. 30

  4. 20

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

When 'a = 10' is declared without 'var' in a non-strict environment, it becomes a global variable. 'var b = 20' declares b in local scope. The addition 'a + b' performs numeric addition (10 + 20 = 30), not string concatenation, because both operands are numbers. The alert correctly displays 30. Option B (1020) would only occur with string concatenation.