Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is meant by constructor?

Answer Posted / dinesh

All the objects that are created must be given initial
values.There are two approach for this.
1)Using the dot operator to access the instance variables
and then assign values to them individually---This is a
tedious approach.
2)Use of getData method to initialize each object
individually.eg:add.getData(10,15)
To make this simpler Java supports a special type of method
called a Constructor,that enables an object to initialize
itself when it is created.Constructor have the same name as
the class itself and they do not specify a return type,not
even void,bcoz they return the instance of the class itself.

Is This Answer Correct ?    23 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about collection interface in java?

989


How many tetrahedral voids are there in bcc?

1091


Is 0 true or false in java?

986


Why pointers are not used in java?

1123


What differences exist between iterator and listiterator?

1040


Can we make constructors static?

1230


What do you mean by formatting?

992


What are the three parts of a lambda expression? What is the type of lambda expression?

1031


What is an 8 bit word?

1047


What is the difference between checked exception and unchecked exception?

1015


What is meant by design patterns?

1024


What is the difference between an interface and an abstract class?

1000


What are drawbacks of singleton class?

954


What is the use of singleton?

958


What is a java list?

1110