Menu
Question Index
...

What will be the output of the following program?

public class ObjectArray
{
    public static void passByReference(String a[])
    {
        a[0] = "Changed";
    }
    public static void main(String args[])
    {
        String[] b = {"Apple", "Mango", "Orange"};
        System.out.println("Before Function Call    " + b[0]);
        ObjectArray.passByReference(b);
        System.out.println("After Function Call    " + b[0]);
    }
}


Before Function Call    Apple
After Function Call    Changed
Before Function Call    Apple
After Function Call    Apple
Before Function Call    Changed
After Function Call    Changed  
Compilation Error or Runtime Error

Doubts

Problems

Topic: Unknown

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App