title: What will be the output of this code and how?
body: <p>**Java code-MySuper class is the parent class and is extended by MySub class.I am creating the object  MySub mySub = new MySub().I thought the output would be &quot;y&quot; but when I tried to run the code it was showing <em>null</em> as an output **</p>
  <pre class="lang-java prettyprint-override"><code>class MySuper {
      String strl = &quot;x&quot;;
  
      public MySuper() {
          myMethod();
      }
  
      void myMethod() {
          System.out.print(strl);
      }
  }
  
  class MySub extends MySuper {
      String str2 = &quot;y&quot;;
  
      void myMethod() {
          System.out.print(str2);
      }
  
      public static void main(String[] args) {
  
          MySub mySub = new MySub();
      }
  }   
  </code></pre>