Menu
Topics Index
...
`

Class with multiple methods1901


If you need explanation Read this topic

If you need Answer Take test on this topic

Class with multiple methods1901
What will be the output of the following program?
public class None {
    void method1(None val1) {
        val1 = null;
    }
    void method2(None val2) {
        val2 = null;
    }
    public static void main(String s[]) {
        None none1 = null;
        None none2 = null;
        new None().method1(none1);
        new None().method2(none2);
        System.out.print(none1 + " ");
        System.out.print(none2);
    }
}

A. null
B. null null
C. (EMPTY)
D. Some other output
E. Compilation Error or Runtime Error
Topic: Java Multiple Methods In One Class

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 B as val1 and val2 is null and prints null  null

Posted by Bharath Yelchuri    2014-06-24 14:22:47


B is the ans.as both none1 and none2 are null

Posted by Shabaaz Shaikz    2014-06-24 14:24:15


ANS: C , there is no return type in the method declaration so the output is EMPTY.

Posted by Damu Surya    2014-06-24 16:40:30


Ans: D,some other output as a blankspace would be printed

Posted by Anmol Chopra    2014-06-24 22:13:29


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

Posted by Merit Campus    2014-06-25 04:06:10


© meritcampus 2019

All Rights Reserved.

Open In App