Saturday, April 27, 2019

what will be the output of the following java code?

Problem statement:
What will be the output of the following java code?
  1. public class ConstructorCall {
  2.     int num = 200;
  3.     public void run(int num) {
  4.         this.num = num;
  5.     }
  6.     public void printE() {
  7.         System.out.println(2 * num);
  8.     }
  9.     public static void main(String[] args) {
  10.         ConstructorCall obj = new ConstructorCall();
  11.         obj.run(10);
  12.         obj.printE();
  13.     }
  14. }
Output: 20

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...