Single Choice Not Set

QDetermine output:
public class Test{
      public static void main(String args[]){
            MyClass obj = new MyClass();
            obj.val = 1;
            obj.call(obj);
            System.out.println(obj.val);
      }
}

class MyClass{
      public int val;
      public void call(MyClass ref){
            ref.val++;
      }
}

ID: #2188 Java Constructor and Methods 820 views
Question Info
#2188Q ID
Not SetDifficulty
Java Constructor and MethodsTopic

Choose the Best Option

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

  • A 1
  • B 2
  • C 3
  • D Compilation Error
Correct Answer

Explanation

2

Share This Question

Challenge a friend or share with your study group.