What will the following code's execution print out?

public class Quizful {
    public static void main(String[] args) {
        Integer one = 1000;
        Integer two = 2000;

        System.out.print((one * 2 == two) ? "yes " : "no ");
        System.out.print((two / 2 == one) ? "yes " : "no ");
    }
}
Explanation
After division or multiplication we will get a primitive int as a result. Therefore, primitives will be compared and in both cases comparison will result in true

There is missing a third line "System.out.println((one == two) ? "yes " : "no ");"

2018 Mar 15, 10:23:28 AM

The right answer is "yesyes", not "yesyesno"! Or something in the question is incorrect...

2017 Jun 20, 3:43:22 PM

Follow CodeGalaxy

Mobile Beta

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