Object oriented java sample exam

后端 未结 6 449
南笙
南笙 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:14

    because we are calling toString in the end. When toString takes value of id to return its always 2. Better to print references one by one .

提交回复
热议问题