Menu
Question Index
...

What will be the output of the following program?

public class Final
{
    final int assign = 35;

    Final()
    {
        final int assign = 10;
        print(assign);
    }

    public static void main(String[] args)
    {
        final int result = 20;
        final int assign;
        
        Final f = new Final();
        assign = 30;

        f.print(result);
        System.out.println(process(result) + ", " + assign + ", " + f.assign);
    }

    static int process(int a)
    {
        return a + 5;
    }

    void print(int assign)
    {
        System.out.print(assign + ", ");
    }
}


10, 20, 25, 30, 10
10, 20, 25, 30, 35
30, 20, 25, 30, 35
Compilation Error because variable assign is declared multiple times
Compilation Error for some other reason

Doubts

Problems

Topic: final Keyword In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App