面试:static 考题

public class Demo {
int a=1;
static int b=1;
Demo(){
a++;
b++;
}
Demo(int c){
this.a=this.a+c;
this.b=this.b+c;
}

public static void main(String[] args) {
Demo t1=new Demo();
Demo t2=new Demo(2);
System.out.println(t1.a);//2
System.out.println(t1.b);//4
System.out.println(t2.a);//3
System.out.println(t2.b);//4
}
}
全部评论
感谢大佬分享!!!!
点赞
送花
回复 分享
发布于 2022-01-13 21:40
啊这个是哪里的考题啊,这么简单
点赞
送花
回复 分享
发布于 2022-01-17 11:35
京东
校招火热招聘中
官网直投

相关推荐

头像
不愿透露姓名的神秘牛友
06-20 00:21
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务