Answer Posted / bindhu
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 ? | 35 Yes | 4 No |
Post New Answer View All Answers
What is ‘has a’’ relationship in java?
Justify your answer that you can't define a method inside another method in java, if you can then how?
What do you mean by platform independence? What is an interface?
What do you mean by byte code?
Why are functions called methods in java?
What is static method with example?
Can you make a constructor final in Java?
Explain the protected field modifier?
Why are arrays useful in java?
What is protected access modifier?
What is parameters example?
How to sort an array from smallest to largest java?
What are adapter classes?
Is arraylist an object in java?
Why is core java important?