Menu
Question Index
...

What will be the output of the following program?

class BaseClass {
    BaseClass() {
        System.out.print("*");
    }
    BaseClass(String str) {
        this();
        System.out.print("@" + str);
    }
}
public class ChildClass extends BaseClass {
    ChildClass() {
        System.out.print("#");
    }
    ChildClass(String name) {
        this();
        System.out.print("$" + name);
    }
    public static void main(String args[]) {
        new ChildClass("hello");
    }
}


*#$hello
*@#$hello    
*@$hello
Some other 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