+ 4

What is the use of constructor Chaining in Java programming?

Any use and who to use it in Java programming

29th Dec 2018, 12:43 AM
hunaysubhash chennu
hunaysubhash chennu - avatar
4 Antworten
29th Dec 2018, 2:58 AM
hunaysubhash chennu
hunaysubhash chennu - avatar
+ 4
You can use it so you'll only need to write a specific code once in one constructor, so you dont need to write it again. Or also you can use them to create object with default value client doesnt pass the parameters. For example you decide to extends a JFrame class. There's no way we know how the jframe are initiated. But with chaining we can call the constructor from JFrame to run as ours by calling super() we can also add additional code after call super(). here's an example https://code.sololearn.com/cImahYGS8N1I/?ref=app
29th Dec 2018, 1:46 AM
Taste
Taste - avatar
+ 3
Combin the constructors in one class
4th Jan 2019, 3:43 AM
Pallavi Malladi
+ 2
One of the pillars of oops concept is INHERITANCE. Inheritance helps in code reusability . To achieve this , dont you think , we need to call the parent class . To call the parent class , Constructor chain is used.... as simple as that....
7th Jan 2019, 7:03 PM
Mohammed Suhail
Mohammed Suhail - avatar