what are the types of constructer explain with example

Answers were Sorted based on User's Feedback



what are the types of constructer explain with example..

Answer / kailash

there are two types of Constructors .
1. Parameterized Constructor inwhich we give arguments .
2. Default constructor , there no argument is given .
for each class there must be a defult constructor .

Is This Answer Correct ?    14 Yes 2 No

what are the types of constructer explain with example..

Answer / siri

there are three kinds parametrized,default and copy consturctor

Is This Answer Correct ?    7 Yes 0 No

what are the types of constructer explain with example..

Answer / 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

More Java Related AllOther Interview Questions

How can I protect myself? : java security

0 Answers  


Why is struts used in java?

0 Answers  


What is the use of rs next () in java?

0 Answers  


there are 67 seats in train . there are only 5 seats in a row and in last row there are only 2 seats. One person can reseve only 5 seat at a time. If person reserving seat , the care is atken that he may get all in row. if seats are not available in row then the arrangement is so that person group get nearby seats. the following class is given public class seat { char name; int seat; boolean isSeatempty } 1.Draw require class digram and object diagram. 2.Write function seatallot(int noofperson) to allocate seat with seat nuber printed for the each name.

0 Answers   Sapient,


What is lambda used for?

0 Answers  






What is a delimiter in java?

0 Answers  


How does java handle integer overflows and underflows?

0 Answers  


What is messaging queue in java?

0 Answers  


explain how java se 8 data and time api solves issues of old java date api?

0 Answers  


I want to control database connections in my program and want that only one thread should be able to make database connection at a time. Define how can I implement this logic?

0 Answers  


what is major difference between component and object?

1 Answers   HCL, Patni,


How long can a lambda function run?

0 Answers  


Categories