ICSE Class 10 Computer Applications
Question 21 of 30
Solved 2025 Specimen Paper ICSE Class 10 Computer Applications — Question 21
Back to all questionsThe code can be rewritten using a single if statement as follows:
if(code == 'g' || code == 'G')
System.out.println("GREEN");Explanation:
- The logical OR operator (
||) is used to check ifcodeis either'g'or'G'. - If either condition is true, the statement
System.out.println("GREEN");will execute. This simplifies the multipleif-elseblocks into a singleifstatement.