Menu
Question Index
...

What will be the output of the following program?

class White {
    White() {
        System.out.print("white is ");
    }
}
class Purple extends White {
    Purple(String color) {
        System.out.print(color);
    }
}
public class Black extends Purple {
    Black() {
        super("beautiful" + ",");
    }
    public static void main(String[] a) {
        new Purple("awesome" + ",");
        new Purple("nice");
    }
}


white is beautiful,nice
white is awesome,nice
white is beautiful,white is nice
Someother output
Compilation Error or Runtime error

Doubts

Problems

Topic: Inheritance And Constructors 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