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 constructer?what are the type of constructer with
example.

Answer Posted / prasad

A constructor is a method.it used to custom intialization
for an object.constructor name and class name is same.
consructor should not return any value not even void also.
A constructor will Executed at the time of initialization of
an object.
Different types of constructors:
--------------------------------
1)default constructor
2)parametarized constructor
Ex:


class sum{
int a,b;//instance variables
sum(int a,int b){
System.out.printl("sum of two numbers="+(a+b));
}
}
class Example{
psvm(String s[])throws Exception{
sum s=new sum(10,10);
}
}
o/p:sum of two numbers=20
/*here the constructor will be executed at the time of
creating the object*/

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Who developed rxjava?

859


How do I run a java project?

895


What is hql in java?

861


What is Map,List,hashtable,ArrayList and difference between them??

2724


when i send the request to the JSP page it will print as it is and why? and how to solve this problem please inform me that solution

1850


For each of the following program segments,give a big zero analysis for the running time 1.For (i=0;i

1919


What is injection in java?

917


Which framework is best for rest api java?

945


What is jpa used for?

945


What is loose coupling in java?

863


What is stateless class in java?

929


What is connection pooling in java?

957


How many types of jdk are there?

989


What is java persistence api used for?

912


What is entitymanager in java?

977