题目内容

假设C是B的子类,B是A的子类,cat是C类的一个对象,bird是B类的一个对象,下列叙述错误的是( )。

A. cat instanceof B的值是true
B. bird instanceof A的值是true
C. cat instanceof A的值是true
D. bird instanceof C的值是true

查看答案
更多问题

对于以下代码,下列叙述正确的是( )。class A{public int i=0;A(int m){i=1;}}public class B extends A{B(int m){i=2;}public static void main(String args[]){B b=new B(100);Sysstem.out.println(b.i);//【代码】}}

A. 程序提示编译错误(原因是A 类没有不带参数的构造方法)
B. 编译无错误,【代码】的输出结果是0
C. 编译无错误,【代码】的输出结果是1
D. 编译无错误,【代码】的输出结果是2

下列叙述正确的是( )。

A. 一个类最多可以实现两个接口
B. 如果一个抽象类实现某个接口,那么它必须重写接口中的全部方法
C. 如果一个非抽象类实现某个接口,那么它可以只重写接口中的部分方法
D. 允许接口中只有一个抽象方法

下列选项中,( )替换程序中标注的【代码】处不会导致编译错误。interface Com{int M=200;int f( );}class ImpCom implements Com{【代码】}

A. public int f( ){return 100+M;}
B. int f( ){return 100;}
C. public double f( ){return 2.6;}
D. public abstract int f( );

阅读以下代码,( )选项正确。1 public interface Com{2abstract void cry( );3public int x=0;4static int y=0;5}6abstract class Cat implements Com{7abstract void cry( );8}

A. 第3行错误
B. 第4行错误
C. 第6行错误
D. 第7行错误

答案查题题库