Saturday, April 27, 2019

what is the output of the code?

Problem statement:
Given the code for constructor overloading. What will be the output?
  1. public class ConstructorCall {
  2.     ConstructorCall() {
  3.         System.out.println("default constructor");
  4.     }
  5.     ConstructorCall(int a){
  6.         this();
  7.         System.out.println("parameterized constructor");
  8.         System.out.println(10);
  9.     }
  10.     public static void main(String[] args) {
  11.         ConstructorCall st = new ConstructorCall(3);
  12.     }
  13. }
Output:
default constructor
parameterized constructor
10

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