题目内容

写出下面题目的运行结果:class Fu { boolean show(char a){ System.out.println(a); return true; }}class Demo extends Fu { public static void main(String[] args) { int i=0; Fu f=new Demo(); Demo d=new Demo(); for(f.show('A'); f.show('B')&&(i<2);f.show('C')) { i++; d.show('D'); } } boolean show(char a) { System.out.println(a); return false; }}

A
B
C. BA
D. AB

查看答案
更多问题

下列选项中关于java中this关键字的说法错误的是( )

A. this关键字是在对象内部指代对象自身的引用
B. this关键字可以在类中的任何位置使用
C. this只和特定的对象关联,而不是和类关联
D. 同一个类的不同对象有不同的this

编译运行如下java代码,输出结果是( )//父类引用不能访问子类特有的属性 class Base{ public void method(){ System.out.print("Base method"); } } class Child extends Base{ public void methodB(){ System.out.print("Child methodB"); } } class Sample{ public static void main(String[] args){ Base base = new Child(); base.methodB(); } }

A. Base method
B. Child methodB
C. Base method Child methodB
D. 编译错误

编译运行如下java代码,输出结果是( ) class Person{ String name = "person"; public void shout(){ System.out.print(name); } } class Student extends Person{ String name = "student"; String school = "school"; } public class Test{ public static void main(String[] args){ Person p = new Student(); p.shout(); } }

A. person
B. student
C. person student
D. 编译错误

public class Animal { int age = 9; public Animal(int age) { this.age = age; } public static void main(String[] args) { Animal animal =new Animal(); System.out.println(animal.age); } }

A. 9
B. 0
C. 编译出错

答案查题题库