Consider the following method...
public void ifTest (boolean flag){ if (flag) //1 if (flag) //2 System.out.println ("True False"); else // 3 System.out.println ("True True"); else // 4 System.out.println ("False False"); }
Which of the following statements are correct ?
Select 3 options
Correct Options are : A C D
Note that if and else do not cascade. They are like opening and closing braces.
if (flag) //1 if (flag) //2 System.out.println ("True False"); else // 3 This closes //2 System.out.println ("True True"); else // 4 This closes //1 System.out.println ("False False");
So, else at //3 is associated with if at //2 and else at //4 is associated with if at // 1