Single Choice 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 921 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

Explanation

0 8
Today: 0 answered · 0 correct
Save progress
Free account

Want to remember what you got wrong?

Create a free account in seconds to track your score, revisit mistakes and continue Programming Language where you left off.

  • Save your progress & streak
  • Topic-wise quizzes & scores
  • Bookmark tricky questions
  • Printable MCQ sets
Practice smarterFree account · save progress
Sign up free

Share This Question

Challenge a friend or share with your study group.