what is default constructor and parameterised constructor
with example?

Answer Posted / tushar

Default constructor: this constructor is created by the compiler automatically whenever an object is created.User don't have to write default constructor every class has its default constructor
Parameterized constructor: this constructor is exclusively written by the coder to assign the initial value to an instance variable.By creating parameterized constructor you can overwrite the default constructor.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is collatration?

3011


How can we find the actual size of an object on the heap?

1055


What is heterogeneous in java?

701


How do you use wildcards?

737


Is 0 true or is 1 true?

701


What’s the difference between the methods sleep() and wait()?

758


Why is whitespace important?

770


What is the advantage of functional interface in java 8?

747


Is it correct to say that due to garbage collection feature in java, a java program never goes out of memory?

797


What is the meaning of course?

812


Is there any way to skip finally block of exception even if some exception occurs in the exception block?

835


What is a vector in java?

775


What is the need of transient variables in Java ?

797


What is nullpointerexception?

751


What is difference between c++ and java ?

856