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

Can I have multiple main methods in the same class?

0 Answers  


What is aop java?

0 Answers  


Do I need both jdk and jre?

0 Answers  


Topic- looping,function overloading,nesting ,polymorphism. Aim - to write a function with a name buzz-buds,that will check whether the given numbers are buddies or not on the basis of no. of parameters passed during function calling.

0 Answers  


What is the content reside in Use case Document?

0 Answers  






why java has the size of character 2 byte ,while in c/c++ it is of 1 byte?

8 Answers   IBS,


What is lsdou? : java security

0 Answers  


Can java program run without jdk?

0 Answers  


what is reflection api? How are they implemented?

0 Answers  


What is reflection in java?

0 Answers  


What is the difference between the boolean & operator and the && operator?

0 Answers  


What is dependency injection in java?

0 Answers  


Categories