Menu
Question Index
...

What will be the output of the following program?

class Moon
{
    public static void main(String [] args)
    {
        Moon O = new Moon();
        O.run();
    }
    
    void run()
    {
        long [] a = {3, 4, 5};
        long [] b = modify(a);
    
        System.out.print(a[0] + a[1] + a[2] + " ");
    
        System.out.println(b[0] + b[1] + b[2]);
    }
    
    long [] modify(long [] c)
    {
        c[1] = 7;
        return c;
    }
}


3 4 5 3 7 5
3 7 5 3 7 5
12 15
15 15
Compilation Error

Doubts

Problems

Topic: Java Multiple Methods In One Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App