Menu
Question Index
...

What will be the output of the following program?

public final class FinalPersonClass {
    private final String name;
    private final int age;
    public FinalPersonClass(final String name, final int age) {
        super();
        this.name = name;
        this.age = age;
    }

    public int getAge() {    return age;    }

    public String getName() {    return name;    }

    public static void main(String[] args) {
        FinalPersonClass fpc = new FinalPersonClass("Oleti", 24);
        FinalPersonClass fc = new FinalPersonClass("Kiran", 25);
        System.out.println(fpc.name + " - " + fpc.age);
        System.out.println(fc.getName() + " - " + fc.getAge());
    }
}


Kiran - 25
Kiran - 25
Oleti - 24
Oleti - 24
Oleti - 24
Kiran - 25
Some other output
Compilation Error or Runtime 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