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
Can we override private method?
What is the purpose of java?
What is a protected method?
What is the difference between compare and compareto in java?
How many ways can an argument be passed to a subroutine and explain them?
Can we override static methods in java?
How do you create immutable object in java?
Explain what is encapsulation?
What is initial size of arraylist in java?
Explain OOPs concept.
How do you define a parameter?
what is instanceof operator used in java?
Can an interface extend another interface?
Which is bigger double or float?
What is qualitative variable?