What will be the result of the following code execution?

public class Main {
    public static void main(String[] args) {
        int i = 0;
        int j = 1;
        System.out.println(i += (j < i) ? (2) : (3)); //1
    }
}
Explanation
Conditional statement (condition) ? (value1) : (value2) is used in the provided example. Condition is placed before the question mark, and is followed by two returned results separated by : sign. If condition results in true then the first value will be returned, othervise - second value will be returned.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes