What will be the result of the main method in the Main class execution?

public class Main {
    private int anInt = 4;

    public Main() {
        anInt = 5;
    }

    public static void main(String[] args) {
        Main m = new Main();
        int anInt = 6;
        m.print(anInt);
    }

    public void print(int anInt){
        System.out.println(anInt);
    }
}
Explanation
Print method parameter will override the scope of the class`s field.

Follow CodeGalaxy

Mobile Beta

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