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

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...