Posts

Showing posts with the label constructors

Constructors in java

Constructors will play key roll in any language while creating an object of a class. In Java, Constructors are useful for create an object of a class. Constructor is also a special method which contains the same name as the class. Constructors differ from other methods in that:             •   Constructors never have an explicit return type.             •   Constructors cannot be directly invoked             •    Constructors cannot be synchronized , final , abstract , native or static . Types of constructors in Java:         There are mainly two types of constructors in Java, one is default constructor and  parametric  constructor. Default Constructor: Default Constructor is a constructor which does not contains any of the parameters. If we are not using any of the  parametric  constructor it is not require...