How to invoke class counstructor in another class without inharetence (extends) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to invoke class counstructor in another class without inharetence (extends)

• The class has 2 private string instance variables flightNo, bookingRef. • The class has 1 private instance variable of the class MyDate. • The class has a multi-argument constructor that sets the value of its instance variables to given values. It should create the object of MyDate and set the values of day, month, and year using appropriate method.

10th Mar 2017, 5:32 PM
Nidal Hassan
Nidal Hassan - avatar
1 Answer
+ 8
Use new YourClass() to invoke the constructor of YourClass.
10th Mar 2017, 7:04 PM
Tashi N
Tashi N - avatar