+ 3

Can a constructor be final?

22nd Sep 2017, 1:10 PM
Roshini D
3 Antworten
+ 3
No! Since every class has it's own constructor, you can't really override constructors anyway, so final would do nothing. (If you don't ever write a constructor for a class, Java generates an empty one!) If you want to make it so you can't extend a class, you can make the class itself final. You can also make constructors private if that is what you want.
22nd Sep 2017, 1:22 PM
Schindlabua
Schindlabua - avatar
+ 1
ya final keyword is like constant so u can't inherit the constructor
22nd Sep 2017, 3:06 PM
Nanda Balakrishnan
0
what is null?
25th Sep 2017, 3:28 PM
phyo ko
phyo ko - avatar