Object oriented java sample exam

后端 未结 6 452
南笙
南笙 2021-01-25 15:52
public class Bird
{
  private static int id = 0;
  private String kind;

  public Bird(String requiredKind)
  {
    id = id + 1;
    kind = requiredKind;
  }

  public S         


        
6条回答
  •  时光说笑
    2021-01-25 16:22

    because here private static int id = 0; id is declared static or class variable. Static variables are class variable they are not initialized or created every time an object is created.

    So, only one copy of static variable exist. No, new copies are created when object are created using new operator.

提交回复
热议问题