Menu
Topics Index
...
`

Static methods1786


If you need explanation Read this topic

If you need Answer Take test on this topic

Static methods1786
What will be the output of the following program?
public class CallBy {
    static void execute(Byte x, Byte y) {
        System.out.println("execute, execute");
    }
    static void execute(Byte x, Byte y, Byte z) {
        System.out.println("execute, execute, execute");
    }
    static void execute(byte... x) {
        System.out.println("execute");
    }
    public static void main(String[] args) {
        byte b = 5;
        execute(b);
        execute(b, b);
        execute(b, b, b);
        execute(b, b, b, b);
    }
}

A. execute
execute, execute
execute, execute, execute
execute, execute, execute, execute
B. execute
execute, execute
execute, execute, execute
execute
C. execute
execute
execute
execute
D. Some other output
E. Compilation Error or Runtime Error
Topic: Static 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:- B

Posted by Ashish Rapol    2013-09-19 08:21:57


Answer is option B : the 1st call will be to the method vch takes any num of parameters that is d last one.. The 2nd to the method having 2 parameters,then to method having 3..dn method having any no. of parameters...thus B will be the o/p.

Posted by Shaik Nyamath    2013-09-19 08:22:25


Ans is B.. since 3rd execute method is the default method fr any number of arguments. for 2 args 1st execute method vl executed and then for 3 args 2nd methd vl beexecuted/..

Posted by Om Prakash Om    2013-09-19 08:43:28


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

Posted by Merit Campus    2013-09-20 04:04:12


© meritcampus 2019

All Rights Reserved.

Open In App