What would be behaviour if the constructor has a return type

date:2024-06-05 12:26:27 author:admin browse: View comments Add Collection

What would be behaviour if the constructor has a return type

What would be behaviour if the constructor has a return type?

a) Compilation error

b) Runtime error

c) Compilation and runs successfully

d) Only String return type is allowed

Answer: a

Explanation: The constructor cannot have a return type. It should create and return new object. Hence it would give compilation error.

支付宝转账赞助

支付宝扫一扫赞助

微信转账赞助

微信扫一扫赞助