Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
- public class Q1 {
- Q1(){
- System.out.println("Default Construcotr");
- }
- Q1(String msg){
- this(); //calls default constructor
- System.out.println("One Argument Constructor");
- }
- }
- class Q2 extends Q1{
- Q2(){
- super();//calls no default constructor of Q1 class.
- /*
- * To call super class constructor with arguments, pass same arguments in
- * super.
- *
- * e.g.
- * super("Hello world") will call Q1(String msg) constructor.
- */
- }
- }

Post new comment