what are the types of constructer explain with example
Answers were Sorted based on User's Feedback
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 |
Answer / siri
there are three kinds parametrized,default and copy consturctor
| Is This Answer Correct ? | 7 Yes | 0 No |
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 |
What is lazy loading in jpa?
What are the advantages of java 8’s date and time api over old date api and joda time api?
why i can not access private variable in other class?
How do you check if java is installed on windows command prompt?
Is jprofiler open source?
Which is better openjdk or oracle jdk?
Why we need method overriding in JAVA ? I mean which method I have to override I can write that method in my Class.
How can the static main method use instance variables?
i have client interview in TCS.client is CITI BANK.how to face it,what type of questions they will ask,please tell send me to kumar525job@gmail.com
what is the serialization?
Write a program using call by refernce for two different classes to explain to print whether a given number is automorphic or not.
Explain the common use of ejb?