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 are the types of constructer explain with example

Answer Posted / srinu

There are Two types of constructors
1)Parameterized constructor in which give the parameter
EX:-
class A1
{

A1(int a)
{
System.out.println("HAI HOW ARE U");
}
}
public class A
{
public static void main(String k[])
{
A1 a1=new A1(5);
}
}
2)Default Constructor :- There are no argument in the
constructor is called Default Constructor
class A1
{

A1()
{
System.out.println("HAI ");
}
}
public class A
{
public static void main(String k[])
{
A1 a1=new A1();
}
}

Note: In our java class their is constructor JVM will create
one default constructor.If our class contain default
constructor or parameter constructor or both then that
time JVM will not create Default constructor

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between map and flatmap in java?

915


What is the difference between collection and stream?

932


What is flatmap in java8?

963


Are jvm’s platform independent?

904


Which is faster c++ or java?

922


What's the difference between local, global and universal groups? : java security

914


Is php faster than java?

866


What about javascript? : java security

1006


Write a class which checks whether a given number is prime or not. Write another class to implement the behavior of previous class and print the series of twin prime number upto a given range.

1834


Can optional be null?

967


What is serializable in java?

829


What is stateless and stateful in java?

1010


How to reverse the singly linked list(In Node data members are(int data,int pointerTONext))

1715


What is ehcache in java?

961


What is optional in java 8? What is the use of optional?advantages of java 8 optional?

918