2019.06.30问题及解析
public class Test {
private int a = 1;
int b = 2;
static int c =3;
public static void main(String[] args) {
Test t = new Test();
//这里插入
}
}
下列成员变量的调用,正确的是?
A.Test.c
B.Test.b
C.this.c
D.t.a
成员变量的调用根据其修饰符的不同,也会有些许不同
一般的成员变量可以通过实例名.成员变量名调用
静态成员变量可以通过类名.成员变量名调用
this不能再静态方法中使用
A.静态变量需要是用类名.变量名,正确
B.类名.变量名无法调用普通成员变量,错误
C.main方法中不能使用this,错误
D.实例名.变量名可以在同一个类中调用私有的成员变量,正确
答案选A、D
2019.07.02问题
运算符——判断执行
题目
public class Test {
public static void main(String[] args) {
int a =100,b = 50, c = a---b, d = a---b;
System.out.print(a + "\t");
System.out.print(b + "\t");
System.out.print(c + "\t");
System.out.print(d + "\t");
}
}
请问上述代码输出的结果为?
A.98 50 50 48
B.98 50 50 49
C.100 49 48 52
D.100 48 48 49