Definition:
Normally method has been executed when manually user call method through object.But Constructor is a method which execute automatically.
In Java, a constructor is a block of codes similar to the method. It is called when an instance of the object is created, and memory is allocated for the object.
It is a special type of method which is used to initialize the object.
Types:
There are two types of constructors in Java:
- Default constructor (no-arg constructor)
- Parameterized constructor
Rules for creating Java constructor
There are two rules defined for the constructor.
- Constructor name must be the same as its class name
- A Constructor must have no explicit return type
- A Java constructor cannot be abstract, static, final, and synchronized
Java has many more important features like Constructor.
To learn these features connect with us @ TCCI Computer Coaching Institute, Ahmedabad.
We teach all Engineering Course , Programming Language , Basic Computer Course , Web Design Course etc..
For more information about Coaching at TCCI.
Call us @ 98256 18292
Visit us @ http://tccicomputercoaching.com/java-language-course/
No comments:
Post a Comment