Assignment: Module 03- Part 03
![]() |
Write a class ConstThisOver and its default constructor to call the parameterized constructor to display the employee number
Use: this keyword to call parameterized constructor.
Input:
10011
Output:
10011
Here is the code for a ConstThisOver class that uses the this keyword to call the parameterized constructor and display the employee number:
class ConstThisOver {
int empNumber;
ConstThisOver() {
this(10011);
}
ConstThisOver(int empNum) {
empNumber = empNum;
}
void display() {
System.out.println("Employee Number: " + empNumber);
}
public static void main(String args[]) {
ConstThisOver obj = new ConstThisOver();
obj.display();
}
}
And here is the output:
Employee Number: 10011