Write the output of the following. Explain your answer.
public class abc {
public static void main(String[] args) {
int c=3, d=4;
if(c++==d)
System.out.println("Yes.");
else if(c++==d)
System.out.println("No.");
}
}
Language: Java.
Answers
Answered by
13
Answered by
1
No output
Explanation:
Actually in your 'if' part, postfix is used, which means the new value will be increemented afterwards so, this is false and the compiler moves to next part without saving this and your second part also has the same condition. hence, both statements are false and you get no output.
Similar questions