Question:What will be the output of the program?
class Test 
{
    static int s;
    public static void main(String [] args) 
    {
        Test p = new Test();
        p.start();
        System.out.println(s);
    }

    void start() 
    {
        int x = 7;
        twice(x);
        System.out.print(x + " ");
    }

    void twice(int x) 
    {
        x = x*2;
        s = x;
    }
}
 

A 7 7 

B 7 14 

C 14 0 

D 14 14 

+ Answer
+ Explanation
+ Report
Total Preview: 1022

Copyright © 2024. Powered by Intellect Software Ltd