当前位置:首页 > java类和对象练习题
B) void f1(int a){} int f1(int a){} C) void f1(){} int f1(int a){} D) int f1(int b){} int f1(int a){}
11. 关于java 中的静态方法,以下说法中正确的是(AC) (选择二项)
A) 静态方法中不能直接调用非静态方法 B) 非静态方法不能直接调用静态方法 C) 静态方法可以用类名直接调用 D) 静态方法里可以使用this 12. 以下代码输出结果为(C )。 public class Animal { }
(选择一项) A) 9
int age = 9;
public Animal(int age) { }
public static void main(String[] args) { }
Animal animal =new Animal(); System.out.println(animal.age); this.age = age;
B) 0 C) 编译出错 D) null
13. 编译运行如下java代码,输出结果是(A) class Person{ }
class Student extends Person{ }
public class Test{ }
(选择一项) A) person B) student C) person student D) 编译错误
public static void main(String[] args){ }
Person p = new Student(); p.shout();
String name = \String school = \String name = \public void shout(){ }
System.out.print(name);
14. 编译运行如下java代码,输出结果是(D)//父类引用不能访问子类特有的属性 class Base{ }
class Child extends Base{ }
class Sample{ }
(选择一项) A) Base method B) Child methodB
C) Base method Child methodB D) 编译错误
15. 下列选项中关于java中this关键字的说法错误的是(B) (选择一项)
A) this关键字是在对象内部指代对象自身的引用
public static void main(String[] args){ }
Base base = new Child(); base.methodB(); public void methodB(){ }
System.out.print(\public void method(){ }
System.out.print(\
B) this关键字可以在类中的任何位置使用 C) this只和特定的对象关联,而不是和类关联 D) 同一个类的不同对象有不同的this
共分享92篇相关文档