单选题:已知代码:
已知代码:
```
class Person{
private static String country="A城市" ;
String name;
public static void sFun(String c){
System.out.println("name="+name);
fun(c);}
public void fun(String c ){
name="name1";
country=c;
}
}
```
关于static,下面描述错误的是 () 。 @[C](1)
A. 上述代码在编译时出错,因为在static方法sFun中访问了非static变量name
B. 上述代码在编译时出错,因为在static方法sFun中访问了非static方法fun()
C. sFun方法正确
D. fun方法正确
A.上述代码在编译时出错,因为在static方法sFun中访问了非static变量name
B.上述代码在编译时出错,因为在static方法sFun中访问了非static方法fun()
C.sFun方法正确
D.fun方法正确
答案:C
```
class Person{
private static String country="A城市" ;
String name;
public static void sFun(String c){
System.out.println("name="+name);
fun(c);}
public void fun(String c ){
name="name1";
country=c;
}
}
```
关于static,下面描述错误的是 () 。 @[C](1)
A. 上述代码在编译时出错,因为在static方法sFun中访问了非static变量name
B. 上述代码在编译时出错,因为在static方法sFun中访问了非static方法fun()
C. sFun方法正确
D. fun方法正确
A.上述代码在编译时出错,因为在static方法sFun中访问了非static变量name
B.上述代码在编译时出错,因为在static方法sFun中访问了非static方法fun()
C.sFun方法正确
D.fun方法正确
答案:C