Answer Posted / ravina gaikwad
Constructor is special type of member function that will
automatically invoke when an object creates. The purpose of
constructor is for the initialization of instance
variables. A constructor having the same name as that of
class name. It may have arguments but doesn't return
anything.
If we want to initialize all objects of the same class
with same values, use default constructor.Otherwise, we can
use parameterized constructor if we want to initialize
objects of the same class with different values. If we
don't specify any constructor , compiler will use default
constructor with garbage value.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the difference between quicksort & mergesort? When should they be used? What is their running time?
What is stringjoiner ?
What is difference between this and super keyword?
Can I overload to string method
Can we have multiple public classes in a java source file?
Can a class be protected in java?
What are the types of casting?
Can you create an object of an abstract class?
what methods would you overwrite in java.lang.object class?
Does list allow duplicates in java?
Which is the best approach for creating thread ?
What is the difference between equals() and == in java?
Write a program to find the whether a number is an Armstrong number or not?
How many ways can we create the string object?
Will minecraft java be discontinued?