Menu
Question Index
...

What is the output of the program?

public class DemoOnEmployee {
    public static void main(String args[]) {
        class Employee {
            public String name;
            public Employee(String name) {
                this.name = name;
            }
            public String getName() {
                return name;
            }
        }
        Object object = new Employee("Merit Campus");
        System.out.println(object.getName());
    }
}


Merit Campus
Compilation Error hence Employee class created in main() method
Compilation Error due to other reasons
Runtime Error

Doubts

Problems

Topic: Advanced Java Programming Concepts

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App