public class AllXas {
public static void main(String[] args) {
int n=7;
boolean logic =(n >0);
if(n >0)
n= -100;
if ( logic ) {
System.out.println(" Positive ");
}else
System.out.println (" Negative ");
}
}
>Solution :
It prints Positive because your logic holds true.
logic holds true because it only evaluated whether n is positive or not only once when your n was 7. Changing n afterwards does not change the value of logic.