ExamVeda
Login
Home
Constructors and Methods
?

Given the following piece of code:
class Person{
        public int number;
}
public class Test{
        public void doIt(int i , Person p){
                i = 5;
                p.number = 8;
        }
        public static void main(String args[]){
                int x = 0;
                Person p = new Person();
                new Test().doIt(x, p);
                System.out.println(x + " " + p.number);
        }
}

What is the result?

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

Join the Discussion

2 Comments
Pratima Kumari
Pratima Kumari 7 years ago
What is the flow of execution
Deep Mahour
Deep Mahour 9 years ago
Can someone explain the result?