Wednesday, August 20, 2008

Constructor in Java

1. A constructor method is special kind of method that determines how an object is initialized when created.

2. Constructor has the same name as class name.

3. Constructor does not have return type.

4. Constructor cannot be over ridden and can be over loaded.

5. Default constructor is automatically generated by compiler if class does not have once.

6. If explicit constructor is there in the class the default constructor is not generated.

7. If a sub class has a default constructor and super class has explicit constructor the code will not compile.

No comments:

private methods on Interface

  Private methods can be used on interface from java 9.   This will help in     Avoiding code duplication.     Ensuring code re-usab...