Menu
Question Index
...

What will be the output of the following program?

public class Final
{
    int lanif = 37;
    int nafi = 21;

    public static void main(String[] args)
    {
        final Final f = new Final();
        f.process2();

        f = modify(f);
        f.process();
    }

    public static final Final modify(final Final f)
    {
        f.process();

        Final f2 = new Final();
        f2.process();

        return f2;
    }

    final void process()
    {
        lanif = nafi + nafi;
        System.out.print(lanif + " " + nafi + " ");
    }

    void process2()
    {
        nafi = lanif % 2;
        System.out.print(nafi + " " + lanif + " ");
    }
}


1 37 2 1 42 21 42 21
18 37 36 18 42 21 42 21
1 37 2 1 1 37 2 1
Compilation Error

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