Menu
Topics Index
...
`

Objects2029


If you need explanation Read this topic

If you need Answer Take test on this topic

Objects2029
What will be the output of following program?
public class ImportantQuestion {
    public static void main(String[] args) {
        Mc mc = new Mc("JAVA");
        System.out.println(Mc.language());
    }
}
final class Mc {
    final String java;
    public Mc(String java) {
        this.java = java;
    }
    public String language() {
        System.out.println(java);
        return java;
    }
}

A. JAVA
B. JAVA
java
C. JAVA
JAVA
D. Some other output
E. Compilation Error or Runtime Error
Topic: final Keyword In Java

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.

ans is E , language is a non static method so it cannot be referenced from static context,if it is mc.language() instead Mc.language() ans will be C

Posted by Raviteja Daggupati    2014-07-25 03:57:15


e..lang is non static cannot be referncd wid static contxt

Posted by Asma Mujtaba Khan    2014-07-25 04:45:44


B

Posted by Samyuktha Reddy    2014-07-25 05:02:11


E , non static method will be called by an object of the class

Posted by Arockia Raj    2014-07-25 05:19:09


'E' language method can't be called through class name as it is an instance member (non static) .
Must be called through reference variable of d object..

Posted by Bharat Khurana    2014-07-25 05:39:59


c

Posted by Ria Gupta    2014-07-25 10:13:33


C

Posted by Neelima Nadikuda    2014-07-25 21:01:30


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

Posted by Merit Campus    2014-07-28 06:52:22


© meritcampus 2019

All Rights Reserved.

Open In App