Day 7: Exploring Constructors :
1.Default Constructor:
We were trying to execute the above code! We haven't assigned any value to the variable brand. But the output we received is null. Any guesses who did that? Yes, it's the default constructor.
As we discussed yesterday, These are the Constructors created by Java when no constructors are explicitly declared in the class. We will not be able to see the code externally. It's internally used to Initializes an object with default values like null for objects, 0 for integers, false for Boolean.
Since the brand variable is not explicitly initialized, its default value (null) will be printed.
2. No Argument Constructor:
These are explicitly defined by the user with no parameter. we can write specific initialization logic when required, even with no parameters. once a constructor is written explicitly it overrides the default constructor.
3.Parameterized Constructor:
This is a constructor that accepts arguments to initialize an object with specific values. we can set up custom values in the time of object creation. We can create number of constructors with different sets of parameters.
We will discuss more on constructors tomorrow. Happy Learning.