Saturday, May 11, 2019

what will be the output of the following code?

Problem statement:
what will be the output of the following code?

  1. class ExecutionEight {
  2.     public int number = 0;
  3. }
  4. public class ExecutionSeven {
  5.     public void doIt(int i, ExecutionEight e) {
  6.         i = 5;
  7.         e.number = 8;
  8.     }
  9.     public static void main(String[] args) {
  10.         int x = 0;
  11.         ExecutionEight e = new ExecutionEight();
  12.         new ExecutionSeven().doIt(x, e);
  13.         System.out.println(x + " " + e.number);
  14.     }
  15. }
Output:
0 8

No comments:

Post a Comment

Blueprint for self-improvement

To learn faster: Make the process fun To understand yourself : Write To understand the world better : Read To build deeper connection : Lis...