Menu
Question Index
...

What will be the output of the following program?

public class Enter {
    public static void main(String[] args) {
        class Horse {
            public String name;
            public Horse(String s) {
                name = s;
            }
        }
        Object obj = new Horse("Hai hello good day");
        Horse h = (Horse) obj;
        System.out.println(h.name);
    }
}


Hai hello good day
(No output)
null
Compilation Error
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