更多“abstract class和interface有什么区别”相关的问题
第1题
现有: 1. abstract class Color { 2.protected abstract String getRGB(); 3. } 4. 5. public class Blue extends Color { 6. //insert code here 7. } 和四个声明: public String getRGB() { return "blue"; } String getRGB() { return "blue"; ) private String getRGB() { return "blue"; } protected String getRGB() { return "blue"; ) 分别插入到第6行,有几个可以通过编译?
点击查看答案
第2题
尝试编译并运行以下代码时会发生什么 class Base{ private void amethod(int iBase){ System.out.println("Base.amethod"); } } class Over extends Base{ public static void main(String argv[]){ Over o=new Over(); int iBase=0; o.amethod(iBase); } public void amethod(int iOver){ System.out.println("over.amethod"); } }
A、编译时错误
B、运行时错误
C、输出Base.amethod
D、输出Over.amethod
点击查看答案
第3题
现有: 1. interface I { void go(); } 2. 3. abstract class A implements I { } 4. 5. class C extends A { 6. void go(){ } 7. } 结果是什么?
A、代码通过编译
B、由于第1行的错误导致编译失败
C、由于笫3行的错误导致编译失败
D、由于第6行的错误导致编译失败
点击查看答案
第4题
String s = new String("xyz");创建了几个String Object?
点击查看答案
第5题
是否可以从一个static方法内部发出对非static方法的
点击查看答案
第7题
Math.round(11.5)等於多少? Math.round(-11.5)等於多
点击查看答案
第8题
作用域public,private,protected,以及不写时的区别
点击查看答案