What are constructors in Java?

Report
Question

Please briefly explain why you feel this question should be reported .

Report
Cancel

Java, constructor known to a block of code which is used to initialize an object. It must have the same name as that of the class. Also, it has no return type and it is automatically called when an object is created.

There are two types of constructors:

  1. Default constructor
  2. Parameterized constructor

A constructor initializes an object when it is created. It has the same name as its class and is syntactically similar to a method. However, constructors have no explicit return type.

In Java Course constructor having more value

Typically, you will use a constructor to give initial values to the instance variables defined by the class, or to perform any other start-up procedures required to create a fully formed object.

0
Education 4 months 0 Answer 243 views Pioneer 0

About preetiagarwalPioneer

Leave an answer

Browse

Captcha Click on image to update the captcha .

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>