{"id":634,"date":"2012-08-22T21:07:25","date_gmt":"2012-08-22T21:07:25","guid":{"rendered":"http:\/\/codeatelier.wordpress.com\/?p=248"},"modified":"2016-08-24T08:44:07","modified_gmt":"2016-08-24T08:44:07","slug":"effect-of-extends-and-object-over-constructor-and-static-method","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/effect-of-extends-and-object-over-constructor-and-static-method\/","title":{"rendered":"Effect of extends and Object over constructor and parent class"},"content":{"rendered":"<p><strong>How Static and Constructor will work when class is Extended<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n  public class Main2 extends A   \r\n  {\r\n   public static void main(String args&#x5B;])\r\n    {\t\r\n\t   \r\n    }\r\n  }\r\n\r\n  class A extends B \r\n  {\r\n    A()\r\n    {\r\n      System.out.println(&quot;I am A Constrctor&quot;);\r\n    }\r\n\t\r\n    static\r\n   {\r\n      System.out.println(&quot;I am Static Method&quot;);\r\n   }\r\n\t\r\n   {\r\n      System.out.println(&quot;Empty&quot;);\r\n   }\r\n }\r\n\r\n class B\r\n {\r\n   B()\r\n   {\r\n     System.out.println(&quot;I am B Constrctor&quot;);\r\n   }\r\n }\r\n<\/pre>\n<p>OP:I am Static Method<\/p>\n<p><strong>How Static and Constructor will work when class object is Created<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n   public class Main2 extends A   \r\n  {\r\n   public static void main(String args&#x5B;])\r\n    {\t\r\n       A objA = new A();  \r\n    }\r\n  }\r\n\r\n  class A extends B \r\n  {\r\n    A()\r\n    {\r\n      System.out.println(&quot;I am A Constrctor&quot;);\r\n    }\r\n\t\r\n    static\r\n   {\r\n      System.out.println(&quot;I am Static Method&quot;);\r\n   }\r\n\t\r\n   {\r\n      System.out.println(&quot;Empty&quot;);\r\n   }\r\n }\r\n\r\n class B\r\n {\r\n   B()\r\n   {\r\n     System.out.println(&quot;I am B Constrctor&quot;);\r\n   }\r\n }\r\n<\/pre>\n<p>OP:I am Static Method<br \/>\nI am B Constrctor<br \/>\nEmpty<br \/>\nI am A Constrctor<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How Static and Constructor will work when class is Extended public class Main2 extends A { public static void main(String args&#x5B;]) { } } class A extends B { A() { System.out.println(&quot;I am A Constrctor&quot;); } static { System.out.println(&quot;I am Static Method&quot;); } { System.out.println(&quot;Empty&quot;); } } class B { B() { System.out.println(&quot;I am B&hellip; <a href=\"https:\/\/codethataint.com\/blog\/effect-of-extends-and-object-over-constructor-and-static-method\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[99],"tags":[],"class_list":["post-634","post","type-post","status-publish","format-standard","hentry","category-classes-and-objects"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=634"}],"version-history":[{"count":1,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/634\/revisions"}],"predecessor-version":[{"id":1466,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/634\/revisions\/1466"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}