首页/ 题库 / [单选题]

1. class&en的答案

1. class Pizza { 
2. java.util.ArrayList toppings; 
3. public final void addTopping(String topping) { 
4. toppings.add(topping);
5. } 
6. } 
7. public class PepperoniPizza extends Pizza { 
8. public void addTopping(String topping) { 
9. System.out.println(”Cannot add Toppings”); 
10. } 
11. public static void main(String[] args) { 
12. Pizza pizza = new PepperoniPizza(); 
13. pizza.addTopping(”Mushrooms”); 
14. } 
15. } 
What is the result?() 

单选题
2021-12-28 23:24
A、 Compilation fails.
B、 Cannot add Toppings
C、 The code runs with no output.
D、 A NullPointerException is thrown in Line 4.
查看答案

正确答案
A

试题解析

感兴趣题目

现有: 
interface Data {public void load();} 
abstract class Info {public abstract void load();}     
下列类定义中正确使用Data和Info的是哪项?() 

在Java语言中,如果你有下面的类定义: 
Abstract class Shape{ Abstract void draw(); } 
class Square extendeds Shape{}
如果你试图编译上面的代码会发生()。 

在Java语言中,如果你有下面的类定义:  
abstract class Shape { 
abstract void draw();    }   
Class Square extends Shape {} 
如果你试图编译上面的代码会发生()。 

路由器的部分配置如下: 
Class-map match-any GOLD 
match ip precedence ef 
class-map match-any SILVER 
Match ip dscp af31 
Policy-map Branch 
Class GOLD 
Priority percent 20 
Class SILVER 
bandwidth percent 15 
random-detect dscp-based 
interface Serial0/1 
description PPP link to BRANCH bandwidth 1536 
ip address 10.200.40.1 255.255.255.252 
encapsulation ppp 
路由器配置VOICE数据流到优先级队列中,但发现并没有起到作用,可能什么原因?()

class java { 
public static void main(String [] java) {  
for (int Java = 1; Java 〈 java.length; Java++)  
System.out.print("java ");  
}  
}  
和命令行: 
java java java java java  
结果为:()  

You have lost all members of your current redo log file group. You issue this query: SQL> select * from v$log; 
GROUP#    SEQ#     BYTES        ARC STATUS            FIRST_NAME 
1                  60           153600        NO INACTIVE            01-03-09:19:34 
2                  61           153600        NO CURRENT            01-03-09:19:50 
You then perform an incomplete recover. You receive this message: ORA-00279: 
change 309141...03/09/01 19:50:14 Needed for thread 1 
ORA-00289: suggestion : /disk1/archive/arch_61.rdo ORA-00280: change 309043 for thread 1 is in  sequence #61 Specify log: {=suggested 
 filename 
 AUTO 
 CANCEL} How should you respond to this message?()

A typical example of a process # 19082 in the /proc file would be:     
# ls -l /proc/19082     
total 0  
dr-xr-xr-x  1  root system 0    Sep 15  15:12  .     
dr-xr-xr-x  1  root system 0    Sept 15 15:12  ..     
-rw-------  1  root system 0    Sept 15  15:12 as     
 -r--------  1  root system 128  Sept 15  15:12 cred     
--w-------  1  root system 0    Sept 15  15:12 ctl     
dr-xr-xr-x  1  root system 0    Sept 15  15:12 lwp    
 -r--------  1  root system 0    Sept 15  15:12 map     
dr-x------  1  root system 0    Sept 15  15:12 object    
 -r--r--r--  1  root system 448  Sept 15  15:12 psinfo    
-r--------  1  root system 1024 Sept 15  15:12 sigact    
 -r--------  1  root system 1520 Sept 15  15:12 status    
 -r--r--r--  1  root system 0    Sept 15  15:12 sysent  
Writing to which of the following files will allow the owner to stop a process?()

You are designing a top-level OU structure to meet the business and technical requirements. 
Which top-evel OU or OUs should you use? ()

现有: 
class Tree { 
private static String tree = "tree "; 
String getTree ()  {  return tree;  }      
} 
class Elm extends Tree { 
private static String tree = "elm "; 
public static void main (String  []  args)  {      
new Elm() .go (new Tree())  ;     
}
} 
void go (Tree t)  { 
String  s =  t.getTree () +Elm.tree  +  tree  +   (new  Elm() .getTree ()) ;     
System.out.println (s) ;}    
结果为:() 
               

import java.io.*; 
public class Forest implements Serializable { 
private Tree tree = new Tree(); 
public static void main(String [] args) { 
Forest f= new Forest(); 
try { 
FileOutputStream fs = new FileOutputStream(”Forest.ser”); 
ObjectOutputStream os = new ObjectOutputStream(fs); 
os.writeObject(f); os.close(); 
} catch (Exception ex) { ex.printStackTrace(); } 
} 
} 
class Tree { } 
What is the result?() 

public class TestOne { 
public static void main (String[] args) throws Exception { 
Thread.sleep(3000); 
System.out.println(”sleep”); 
} 
} 
What is the result?() 

public class A extends Thread { 
A() { 
setDaemon(true); 
} 
public void run() { 
(new B()).start(); 
try { 
Thread.sleep(60000); 
} catch (InterruptedException x) {} 
System.out.println(“A done”); 
} 
class B extends Thread { 
public void run() { 
try { 
Thread.sleep(60000); 
} catch (InterruptedException x) {} 
System.out.println(“B done”); 
} 
} 
public static void main(String[] args) { 
(new A()).start(); 
} 
}  
What is the result?()  

相关题目

阅读以下代码: 
public class Test{ 
public static void main(){ 
System.out.println(“x=”+x);   } } 
请问,代码运行的结果是?() 

public class Car { 
private int wheelCount; 
private String vin; 
public Car(String vin) { 
this.vin = vin; 
this.wheelCount = 4; 
} 
public String drive() { 
return “zoom-zoom”; 
} 
public String getInfo() { 
return “VIN: “+ vin + “wheels: “+ wheelCount; 
} 
} 
And: 
public class MeGo extends Car { 
public MeGo(String vin) { 
this.wheelCount = 3; 
} 
} 
What two must the programmer do to correct the compilation errors?()

1. class Pizza { 
2. java.util.ArrayList toppings; 
3. public final void addTopping(String topping) { 
4. toppings.add(topping);
5. } 
6. } 
7. public class PepperoniPizza extends Pizza { 
8. public void addTopping(String topping) { 
9. System.out.println(”Cannot add Toppings”); 
10. } 
11. public static void main(String[] args) { 
12. Pizza pizza = new PepperoniPizza(); 
13. pizza.addTopping(”Mushrooms”); 
14. } 
15. } 
What is the result?() 

 public class X { 
 public static void main (String[]args)   { 
 string s = new string (“Hello”); 
 modify(s); 
 System.out.printIn(s); 
 } 
 public static void modify (String s)  { 
 s += “world!”;  
   } 
 }     
What is the result?()  

分析下列Java代码:  
class A { 
public static void main(String[] args)    {  
method();   }     
static void method()    {     try    { 
System.out.println("Hello");    System.exit(0);    }   
finally   { 
System.out.println("good-bye");  }   }    } 
编译运行后,输出结果是()。  
  

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?() 

在Java语言中,小明在他的包mypackage中定义了类My_Class, 在mypackage的子包mysubpackage中也有个类My_Class。小明用 import mypackage.*;引入包, 执行其中的语句: My_Class NewClass = new My_Class();时,将发生()。 

1. public class SimpleCalc { 
2. public int value; 
3. public void calculate() { value += 7; } 
4. }
And: 
1. public class MultiCalc extends SimpleCalc { 
2. public void calculate() { value -= 3; } 
3. public void calculate(int multiplier) { 
4. calculate(); 
5. super.calculate(); 
6. value *=multiplier; 
7. } 
8. public static void main(String[] args) { 
9. MultiCalc calculator = new MultiCalc(); 
10. calculator.calculate(2); 
11. System.out.println(”Value is: “+ calculator.value); 
12. } 
13. } 
What is the result?() 

What is wrong with the following code?()  
class MyException extends Exception {}  
public class Qb4ab {  
public void foo() {  try {  bar();  } finally {  baz();  
} catch (MyException e) {} 
}  
public void bar() throws MyException {  
throw new MyException(); 
}  
public void baz() throws RuntimeException {  
throw new RuntimeException(); 
 }  
}  

现有: 
class Birds { 
public static void main (String  []  args)  {  
try { 
throw new Exception () ;   
} catch (Exception e) {  
try { 
 throw new Exception () ; 
}  catch  (Exception e2)  {  System.out.print ("inner           "); } 
 System. out.print ( "middle" ) ;   
} 
System.out.print ("outer") ;   
}   
} 
结果是()

Given:  
11. static class A {  
12. void process() throws Exception { throw new Exception(); }  
13. }  
14. static class B extends A {  
15. void process() { System.out.println("B "); }  
16. }  
17. public static void main(String[] args) {  
18. A a = new B();  
19. a.process();  
20. }  
What is the result? ()

11. static class A { 
12. void process() throws Exception { throw new Exception(); } 
13. } 
14. static class B extends A { 
15. void process() { System.out.println(”B”); } 
16. } 
17. public static void main(String[] args) { 
18. new B().process(); 
19. } 
What is the result?() 

11. static classA { 
12. void process() throws Exception { throw new Exception(); } 
13. } 
14. static class B extends A { 
15. void process() { System.out.println(”B “); } 
16. } 
17. public static void main(String[] args) { 
18.A a=new B(); 
19. a.process(); 
20.} 
What is the result?() 

1. class Exc0 extends Exception { } 
2. class Exc1 extends Exc0 { } 
3. public class Test { 
4. public static void main(String args[]) { 
5. try { 
6. throw new Exc1(); 
7. } catch (Exc0 e0) { 
8. System.out.println(“Ex0 caught”); 
9. } catch (Exception e) { 
10. System.out.println(“exception caught”); 
11. } 
12. } 
13. } 
What is the result?()  

Class TestException 
1. public class TestException extends Exception { 
2. } Class a: 
1. public class a { 
2. 
3. public String sayHello(String name) throws TestException { 
4. 
5. if(name == null) { 
6. throw new TestException(); 
7. } 
8. 
9. return “Hello “+ name; 
10. } 
11. 
12. } 
A programmer wants to use this code in an application:
45. A a=new A(); 
46. System.out.println(a.sayHello(”John”)); 
Which two are true?()

Which statements concerning the relationships between the following classes are true?()  
class Foo {  int num;  
Baz comp = new Baz();  
}  
class Bar {  boolean flag;  
}  
class Baz extends Foo {  
Bar thing = new Bar();  
double limit;  
}  

int index = 1; 
boolean[] test = new Boolean[3]; 
boolean foo= test [index];  
What is the result?()  

int index = 1;  
boolean test = new Boolean;  
boolean foo= test [index]; 
What is the result?()

String foo = “blue”; 
Boolean[]bar = new Boolean [1]; 
if (bar[0])  { 
foo = “green”; 
}  
What is the result? () 

Given that Thing is a class, how many objects and reference variables are created by the following code?()  
Thing item, stuff;  
item = new Thing();  
Thing entity = new Thing();

广告位招租WX:84302438

免费的网站请分享给朋友吧