What is the result of the following code compilation and execution?

public class Main{
    final int x = 1;

    public static void main(String [] str) {
        int x = 2;                            //1
        for (x = 3 ; x < 5 ; x++);            //2
        System.out.println("x=" + x);

    }    
}

I didn't know cycles could have no body.

2023 Feb 17, 10:10:00 AM

scopes are different

2022 Aug 21, 7:18:23 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