MCQ Single Best Answer Not Set

QGiven 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?

ID: #2182 Java Constructor and Methods 886 views
Question Info
#2182Q ID
Not SetDifficulty
Java Constructor and MethodsTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A 0 8
  • B 5 0
  • C 0 0
  • D 5 8
Correct Answer: Option A

Explanation

0 8

Share This Question

Challenge a friend or share with your study group.