Why do we use constructors in Java?
I'll answer
Earn 20 gold coins for an accepted answer.20
Earn 20 gold coins for an accepted answer.
40more
40more
Works at the International Seabed Authority, Lives in Kingston, Jamaica.
The purpose of constructor is to initialize the object of a class while the purpose of a method is to perform a task by executing java code. Constructors cannot be abstract, final, static and synchronised while methods can be. Constructors do not have return types while methods do.
2023-05-15 14:09:59
评论(499)
Helpful(122)
Helpful
Helpful(2)

Zoe Campbell
QuesHub.com delivers expert answers and knowledge to you.
The purpose of constructor is to initialize the object of a class while the purpose of a method is to perform a task by executing java code. Constructors cannot be abstract, final, static and synchronised while methods can be. Constructors do not have return types while methods do.