Question about constructors in Java

前端 未结 8 642
我寻月下人不归
我寻月下人不归 2021-01-20 14:52

I have few questions regarding Java constructors

  1. Can a constructor be private? If yes then in which condition?
  2. Is a constructor a method or not?
8条回答
  •  离开以前
    2021-01-20 15:32

    The default access modifier of a constructor is CLASS ACCESS MODIFIER, If a class is public , then access modifier of a constructor is public. If the class is default , then constructor is also default.

提交回复
热议问题