ExamVeda
Login
Home
This question belongs to Java Program Flow Control
Flow Control
?

What will be the output of the following Java 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();     
    }
}

Answer & Solution
Correct Answer: Option B
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.