Menu
Topics Index
...
`

Creating Class with multiple methods And Method Overloading


If you need explanation Read this topic

If you need Answer Take test on this topic

Creating Class with multiple methods And Method Overloading
What is the output of following program?
public class RiversOverflow {

    public static void main(String[] args) {
        int a = 0;
        int b = 9;
        RiversOverflow ro = null;
        int c = ro.ganga(a, b);
        long d = ro.yamuna(a, b);
        ro = new RiversOverflow();
        long e = ro.ganga(c, d);
        System.out.print("a" + b + "c" + d + "e");
    }

    private static int ganga(int a, int b) {
        System.out.print("a" + b);
        return a + b;
    }

    private static int yamuna(int b, int a) {
        System.out.print(a + "b");
        return a - b;
    }

    private long ganga(int a, long b) {
        System.out.print(a + b);
        return a + b;
    }
}

A. 9909
B. a99b18a9c9e
C. a90b0a9c-9e
D. Some other output
E. Compilation Error or Runtime Error
Topic: Creating Static Methods In Java Using Static Keyword

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...first func prints a9 n returns 9...2nd func prints 9b n returns 9 ...third func ptints 18 n returns 0 ...sop in main prints a9c9e

Posted by Mânïshå Mùlchåndânï    2014-09-08 09:42:01


B

Posted by Rajat Panjwani    2014-09-08 10:01:23


Ans is D.. output is "a9c9099e".. string + variable =string.. "a"+9+"c"+"909"+"e"..

Posted by Om Prakash Om    2014-09-08 10:11:26


B

Posted by Pranavi Prakash    2014-09-08 11:40:26


ans is B

Posted by Raju VarshnEy    2014-09-08 12:08:08


C

Posted by Rohit Baranwal    2014-09-08 14:49:45


Congratulations Mânïshå Mùlchåndânï. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-09-09 04:15:33


© meritcampus 2019

All Rights Reserved.

Open In App