Menu
Topics Index
...
`

static and non static methods


If you need explanation Read this topic

If you need Answer Take test on this topic

static and non static methods
What will be the output of the following program?
public class CanYouGuess {
    public static void main(String[] args) {
        System("a", "b", "c", "d", "e", "f");
        Radio('f', 'e', 'd', 'c', 'b', 'a');
        TV(1, 2, 3, 4, 5, 6, 7, 8, 9);
        new CanYouGuess().Mobile(0.0, 0, 0, 2.0);
    }
    void Mobile(double... d) {
        System.out.print(d[3]);
    }
    static void System(String... str) {
        for (String c : str)
            System.out.print(c);
        System.out.println();
    }
    static void Radio(char... chr) {
        for (char c : chr)
            System.out.print(c);
        System.out.println();
    }
    static void TV(int... is) {
        for (int i : is)
            System.out.print(i);
        System.out.println();
    }
}

A. nullnullnull
nullnullnull
nullnullnull
2.0
B. abcdef
fedcba
123456789
2.0
C. abc
fed
123
2.0
D. Some other output
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.

Ans is B,wen we are passing to System method set of strings n we are recvng there as varargs and printg using for each loop,similarly to chars and integers..here we are calling Mobile() with obj becz its nt an static method, here we are printg element at 3 rd locations means 2.0 so Ans is B

Note: why varargs,  y nt array? is while passing group of elemnts v cant recv throgh an array so varargs is the option

Posted by Uday Kumar    2014-03-13 13:08:26


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

Posted by Merit Campus    2014-03-14 04:07:33


© meritcampus 2019

All Rights Reserved.

Open In App