ADVANCED TOPICS IN COMPILER DESIGN
CODE GENERATION FOR OBJECT ORIENTED LANGUAGES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
True
|
|
False
|
|
Either A or B
|
|
None of the above
|
Detailed explanation-1: -If you require code to run only when the statement returns true (and do nothing else if false) then an else statement is not needed. On the other hand if you need a code to execute “A” when true and “B” when false, then you can use the if / else statement.
Detailed explanation-2: -If the conditional statement is true, the code block included within the if statement is executed. But, if the condition is not met, the code inside the curly brackets is skipped, and the next if statement will be executed.
Detailed explanation-3: -1. The else statement is required in using if statement-Answer is False as you can write only if statement, if you want to do an action if condition is true. Standalone if statements are valid.
Detailed explanation-4: -You can have an if statement without a corresponding else statement.