Problem statement:
Given the code for constructor overloading. What will be the output?
Given the code for constructor overloading. What will be the output?
- public class ConstructorCall {
- ConstructorCall() {
- System.out.println("default constructor");
- }
- ConstructorCall(int a){
- this();
- System.out.println("parameterized constructor");
- System.out.println(10);
- }
- public static void main(String[] args) {
- ConstructorCall st = new ConstructorCall(3);
- }
- }
Output:
default constructor
parameterized constructor
10
No comments:
Post a Comment