Menu
Topics Index
...
`

Class with multiple methods1783


If you need explanation Read this topic

If you need Answer Take test on this topic

Class with multiple methods1783
What will be the output of the following program?
public class Extension {
    static void helloLong(long... x) {
        System.out.println("This is Long");
    }
    static void helloInteger(Integer... x) {
        System.out.println("This is Integer");
    }
    static void helloString(String... str) {
        System.out.println("This is " + str[0]);
    }
    public static void main(String[] args) {
        int mC = 5;
        helloLong(mC, mC);
        helloInteger(mC, mC);
        helloString("String");
    }
}

A. This is Long
This is Integer
This is String
B. This is Long
This is Integer
This is
C. This is String
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.

A

Posted by Maheshwari Natarajan    2014-07-04 03:34:59


option A
return-type function_name(arguments....)
arguments.... indicates expecting an array of arguments of 'n' number may be zero also...
in method helloString str[0] indicates first argument which is "String"

Posted by Sasikanth Sharma    2014-07-04 03:36:29


Ans A static methods within the class can be directly invoked inside main compiler implicitly treats it as this.hellolong(). Etc...n var-args passed to methods stores in the form of an array...int passed in hellolong is implecitly type casted to long

Posted by Srinivas Nalla    2014-07-04 03:50:57


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

Posted by Merit Campus    2014-07-07 05:24:17


© meritcampus 2019

All Rights Reserved.

Open In App