Problem of the Day
Friday, June 5, 2026
Problem:
A variable in a computer program has a name and refers to a value. What are the values of variables v1, v2, v3, and v4 after the following code is executed?
int v1;
double v2;
String v3;
boolean v4;
v1 | v2 | v3 | v4 | |
| a. | 0 | 0 | "" | true |
| b. | 0 | 0.0 | "" | false |
| c. | 0 | 0.0 | null | false |
| d. | null | null | null | false |
The correct answer is c. Primitive values such as int, double, and boolean values, if not initialized to some other value when they are declared, have default values of 0, 0.0, and false, respectively. Objects such as instances of the String class, or any other class, have a value of null until they are initialized.