Menu
Topics Index
...
`

Classes2028


If you need explanation Read this topic

If you need Answer Take test on this topic

Classes2028
What will be the output of following program?
public class EcoGreen {
    EcoGreen get() {
        return this;
    }
    public static void main(String[] args) {
        new Green().get().message();
    }
}
class Green extends EcoGreen {
    Green get() {
        return this;
    }
    void message() {
        System.out.print("www.facebook.com/java.meritcampus");
    }
}

A. www.facebook.com/java.meritcampus
www.facebook.com/java.meritcampus
B. www.facebook.com/java.meritcampus
C. Some other output
D. Output can not be determined
E. Compilation Error or Runtime Error
Topic: Unknown

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

B is the answer here we r creating object Green class and with that we r calling message method..

Posted by Ankit Mudiraj    2013-12-18 08:49:20


B

Posted by Gopinath Manchikanti    2013-12-18 09:21:45


Option B is correct, because based on Green class reference we r calling method "message"....so that it will print that output

Posted by Shreenath Chandrakanth    2013-12-18 12:47:48


Congratulations Shreenath Chandrakanth. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2013-12-19 03:50:56


© meritcampus 2019

All Rights Reserved.

Open In App