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

Can we call a non-static method from inside a static method?

1003


Can we override data members in java?

1147


What are the approaches that you will follow for making a program very efficient?

1079


What is use of set in java?

1006


What is a treeset class?

1015


What is meant by interface?

1063


What is object-oriented programming?

1129


Why do we use bufferedreader?

1015


What is difference between word and integer?

1084


Explain wrapper classes in java?

1005


What is the difference between access specifiers and access modifiers in java? 16

1004


What is oops in java?

1025


What best practices should you follow while writing multithreaded code in java?

1078


What is thread life cycle in java?

1072


What is the difference between Array and Hash Table?

1038