4、下列关于this关键字的说法中,错误的是()。
A. this可以解决成员变量与局部变量重名问题
B. this出现在成员方法中,代表的是调用这个方法的对象
C. this可以出现在任何方法中
D. this相当于一个引用,可以通过它调用成员方法与属性
5、下列程序的运行结果是()。public class Test {public static void test() {this.print();}public static void print() {System.out.println("Test");}public static void main(String args []) {test();}}
A. 输出Test
B. 无输出结果
C. 编译错误,指示不能在static上下文中使用this
D. 以上都不对
6、在Java中,以下程序编译运行后的输出结果为()。public class Test {int x, y;Test(int x, int y) {this.x = x;this.y = y;}public static void main(String[] args) {Test pt1, pt2;pt1 = new Test(3, 3);pt2 = new Test(4, 4);System.out.print(pt1.x + pt2.x);}}
A. 7
B. 6
C. 3 4
D. 8
7、下列程序的运行结果是()。public class Test {private String name;Test(String name){this.name = name;}private static void show(){System.out.println(name) ;}public static void main(String[] args){Test d = new Test("lisa");d.show();}}
A. 输出lisa
B. 输出null
C. 输出name
D. 编译失败,无法从静态上下文中引用非静态变量name