What will be the output of the following Java code? [code] class access { public int x; private int y; void

Quang Hiếu

New member
What will be the output of the following Java code?
Code:
    class access
    {
        public int x;
 	private int y;
        void cal(int a, int b)
        {
            x =  a + 1;
            y =  b;
        }   
        void print() 
        {
            System.out.println(" " + y);     
        } 
    }   
    public class access_specifier 
    {
        public static void main(String args[])
        {
            access obj = new access();   
            obj.cal(2, 3);
            System.out.println(obj.x);
            obj.print();     
        }
   }
A. 2 3
B. 3 3
C. Runtime Error
D. Compilation Error
 

Tìm kiếm

Back
Top