title: Invoking the default constructor (in Java) in a class that only has a defined constructor that requires parameters
body: <p>Please tell me if I have the proper understanding of the following code:</p>
  
  <pre><code>public class Test {
    public static void main(String[] args) {
      A a = new A();
      a.print();
    }
  }
  
  class A {
    String s;
  
    A(String s) {
      this.s = s;
    }
  
    void print() {
      System.out.println(s);
    }
  }
  </code></pre>
  
  <p>The line “A a = new A();” invokes the class/constructor to create a new object with reference variable “a”. Class A has a defined constructor that requires a string argument, thus it does not have the default constructor. This means that the instantiation without any string arguments causes a compiler error. </p>
  
  <p>If I were to add a string argument into the instantiation, e.g. A a = new A("goldfish");    the program would compile and run.</p>
  
  <p>I am not sure if I have used the right vocabulary for this, so feel free to correct anything that is inaccurate/confusing. Thanks!</p>