ADVANCED TOPICS IN COMPILER DESIGN
CODE GENERATION FOR OBJECT ORIENTED LANGUAGES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
What is the output of the following code snippet?int i = 0 ; for (i = 0 ; i < 5 ; i++){ } System.out .println(i);
|
5
|
|
0
|
|
4
|
|
Compilation Error
|
Explanation:
Detailed explanation-1: -Program to Count the Number of Digits = 0 is evaluated to 0 (false).
Detailed explanation-2: -i++ operator returns a copy of the earlier value whereas ++i returns a reference to the number itself after increment. Here by the time, ++i is output to the terminal, it’s value has been changed by two computations.
There is 1 question to complete.