网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
1. interface A { public void aMethod(); } 2. interface B { public void bMethod(); } 3. interface C extends A,B { public void cMethod(); } 4. class D implements B { 5. public void bMethod() { } 6. } 7. class E extends D implements C { 8. public void aMethod() { } 9. public void bMethod() { } 10. public void cMethod() { } 11. } What is the result?()
- A、 Compilation fails because of an error in line 3.
- B、 Compilation fails because of an error in line 7.
- C、 Compilation fails because of an error in line 9.
- D、 If you define D e = new E(), then e.bMethod() invokes the version of bMethod()defined in Line 5.
- E、 If you define D e = (D)(new E()),then e.bMethod() invokes the version of bMethod() defined in Line 5.
- F、 If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.
参考答案
更多 “ 1. interface A { public void aMethod(); } 2. interface B { public void bMethod(); } 3. interface C extends A,B { public void cMethod(); } 4. class D implements B { 5. public void bMethod() { } 6. } 7. class E extends D implements C { 8. public void aMethod() { } 9. public void bMethod() { } 10. public void cMethod() { } 11. } What is the result?() A、 Compilation fails because of an error in line 3.B、 Compilation fails because of an error in line 7.C、 Compilation fails because of an error in line 9.D、 If you define D e = new E(), then e.bMethod() invokes the version of bMethod()defined in Line 5.E、 If you define D e = (D)(new E()),then e.bMethod() invokes the version of bMethod() defined in Line 5.F、 If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.” 相关考题
考题
ArraryList a = new ArrayList(); a.add(“Alpha”); a.add(“Bravo”): a.add(“Charlie”); a.add(“Delta”); Iterator iter = a.iterator(); Which two, added at line 17, print the names in the ArrayList in alphabetical order?()A、 for (int i=0; i a.size(); i++) System.out.println(a.get(i)));B、 for (int i=0; i a.size(); i++) System.out.println(a[i]);C、 while( iter.hasNext() ) System.out.println(iter.next()) ;D、 for (int i=0, i a.size(); i++) System.out.println(iter[i]);E、 for (int i=0; i a.size(); i++) System.out.println(iter.get(i));
考题
class A { public String toString () { return “4”; } } class B extends A { 8. public String toString () { return super.toString() + “3”; } } public class Test { public static void main(Stringargs) { System.out.printIn(new B()); } } What is the result?() A、 Compilation succeeds and 4 is printed.B、 Compilation succeeds and 43 is printed.C、 An error on line 9 causes compilation to fail.D、 An error on line 14 causes compilation to fail.E、 Compilation succeeds but an exception is thrown at line 9.
考题
Which two construct an OutputSream that appends to the file “file.txt”? ()A、 OutputStream out=new FileOutputStream(“file.txt”);B、 OutputStream out=new FileOutputStream(“file.txt”, “append”);C、 FileOutputStream out=new FileOutputStream(“file.txt”, true);D、 FileOutputStream out=new FileOutputStream(new file(“file.txt”));E、 OutputStream out=new FileOutputStream(new File(“file.txt”)true);
考题
Assuming that the serializeBanana2() and the deserializeBanana2() methods will correctly use Java serialization and given: import java.io.*; class Food {Food() { System.out.print(”1”); } } class Fruit extends Food implements Serializable { Fruit() { System.out.print(”2”); } } public class Banana2 extends Fruit { int size = 42; public static void main(String [] args) { Banana2 b = new Banana2(); b.serializeBanana2(b); // assume correct serialization b = b.deserializeBanana2(b); // assume correct System.out.println(” restored “+ b.size + “ “); } // more Banana2 methods } What is the result?() A、 Compilation fails.B、 1 restored 42C、 12 restored 42D、 121 restored 42E、 1212 restored 42F、 An exception is thrown at runtime.
考题
在java中,引用对象变量和对象间有什么关系?()A、对象与引用变量的有效期不一致,当引用变量不存在时,编程人员必须动手将对象删除,否则会造成内存泄露。B、对象与引用变量的有效期是一致的,当引用变量不存在时,它所指向的对象也会自动消失。C、对象与引用变量的有效期是一致的,不存在没有引用变量的对象,也不存在没有对象引用变量。D、引用变量是指向对象的一个指针。
考题
下面说法正确的为()A、实现同一接口的两个类之间是紧耦合的B、封装可以提高类的重用性C、封装好的类只允许子类覆盖方法,不允许子类重载方法D、封装好的类允许修改方法的实现,而不影响外部代码
考题
try { if ((new Object))(.equals((new Object()))) { System.out.println(“equal”); }else{ System.out.println(“not equal”); } }catch (Exception e) { System.out.println(“exception”); } What is the result? () A、 equalB、 not equalC、 exceptionD、 Compilation fails.
考题
定义类: package utils; public class Rep{ public static String twice (String s){return s+s ;} } 再定义另一个类Demo: //insert code here public class Demo{ public static void main (String[] args){ System. out .println( twice( "Hello")); } } 在第一行插入哪项代码,可以使程序正常编译和执行?() A、import utils.*;B、 import utils.Rep.*;C、 import static utils.Rep.twice;D、 static import utils.Rep.twice;
热门标签
最新试卷