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;

    public void print(int anInt){
Print method parameter will override the scope of the class`s field.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback