Compilation fails.
Cannot add Toppings
The code runs with no output.
A NullPointerException is thrown in Line 4.
第1题:
阅读下列说明和 C++代码,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 某快餐厅主要制作井出售儿童套餐,一般包括主餐(各类比萨)、饮料和玩具,其餐品种类可能不同,但其制作过程相同。前台服务员(Waiter)调度厨师制作套餐。现采用生成器(Builder) 模式实现制作过程,得到如图 5-1 所示的类图。图5-1 类图 【C++代码】 include<iostream> include <string> using namespace std; class Pizza { private: string parts; public: void setParts(string parts) { this->parts=parts; } string getParts() { return parts; } }; class PizzaBuilder { protected:Pizza* pizza; public: Pizza* getPizza() { retum pizza; } void createNewPizza() { pizza = new Pizza(); } ( 1 ); } class HawaiianPizzaBuilder :public PizzaBuilder { public: void buildParts() { pizza->setParts("cross +mild + ham&pineapple"); } }; class SpicyPizzaBuider: public PizzaBuilder { public: void buildParts() { pizza->setParts("pan baked +hot + ham&pineapple"); } } Class Waiter{ Private: PizzaBuilder* pizzaBuilder; public: void setPizzaBuilder(PizzaBuilder* pizzaBuilder) { /*设置构建器*/ ( 2 ) } Pizza* getPizza() { return pizzaBuilder->getPizza(); } void construct() { /*构建*/ pizzaBuilder->createNewPizza(); ( 3 ) } }; int main(){ Waiter*waiter=new Waiter(); PizzaBuilder*hawaiian pizzabuilder=new HawaiianPizzaBuilder() ( 4 ); ( 5 ); cout<< "pizza: "<< waiter->getPizza()->getParts()<< endl; } 程序的输出结果为: pizza: cross + mild + ham&pineapple
第2题:
食品处理区分为1.()2.()3.()
第3题:
A、1.指导填写凭证;2.出纳审核盖章;3.领导审批签字;4.出纳清点支付
B、1.指导填写凭证;2.出纳清点支付;3.领导审批签字;4.出纳审核盖章
C、1.指导填写凭证;2.领导审批签字;3.出纳审核盖章;4.出纳清点支付
D、1.指导填写凭证;2.出纳审核盖章;3.出纳清点支付;4.领导审批签字
第4题:
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?()
第5题:
1. public class Target { 2. private int i = 0; 3. public int addOne() { 4. return ++i; 5. } 6. } And: 1. public class Client { 2. public static void main(String[] args) { 3. System.out.println(new Target().addOne()); 4. } 5. } Which change can you make to Target without affecting Client?()
第6题:
阅读下列说明和 Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。 【说明】 某快餐厅主要制作并出售儿童套餐,一般包括主餐(各类比萨)、饮料和玩具,其餐品种类可能不同,但其制作过程相同。前台服务员 (Waiter) 调度厨师制作套餐。现采用生成器 (Builder) 模式实现制作过程,得到如图 6-1 所示的类图。【Java代码】 class Pizza { private String parts; public void setParts(String parts) { this.parts = parts; } public String toString() { return this.parts; } } abstract class PizzaBuilder { protected Pizza pizza; public Pizza getPizza() { return pizza; } public void createNewPizza() { pizza = new Pizza(); } public (1) ; } class HawaiianPizzaBuilder extends PizzaBuilder { public void buildParts() { pizza.setParts("cross + mild + ham&pineapp1e”}; } class SpicyPizzaBuilder extends PizzaBuilder { public void buildParts() { pizza.setParts("pan baked + hot + pepperoni&salami"); } } class Waiter { private PizzaBuilder pizzaBuilder; public void setPizzaBuilder(PizzaBuilder pizzaBuilder) { /*设置构建器*/ ( 2 ) ; } public Pizza getPizza(){ return pizzaBuilder.getPizza(); } public void construct() { /*构建*/ pizzaBuilder.createNewPizza(); ( 3 ) ; } } Class FastFoodOrdering { public static viod mainSting[]args) { Waiter waiter = new Waiter(); PizzaBuilder hawaiian_pizzabuilder = new HawaiianPizzaBuilder(); ( 4 ) ; ( 5 ) ; System.out.println("pizza: " + waiter.getPizza()); } } 程序的输出结果为: Pizza:cross + mild + ham&pineapple
第7题:
1. public class ReturnIt { 2. return Type methodA(byte x, double y) { 3. return (long)x / y * 2; 4. } 5. } What is the narrowest valid returnType for methodA in line2?()
第8题:
A、1.核对收款依据;2.收取款项;3.开具收款证明
B、1.收取款项;2.核对收款依据;3.开具收款证明
C、1.开具收款证明;2.核对收款依据;3.收取款项
D、1.核对收款依据;2.开具收款证明;3.收取款项
第9题:
1. public interface A { 2. public void doSomething(String thing); 3. } 1. public class AImpl implements A { 2. public void doSomething(String msg) { } 3. } 1. public class B { 2. public A doit() { 3. // more code here 4. } 5. 6. public String execute() { 7. // more code here 8. } 9. } 1. public class C extends B { 2. public AImpl doit() { 3. // more code here 4. } 5. 6. public Object execute() { 7. // more code here 8. } 9. } Which statement is true about the classes and interfaces in the exhibit?()
第10题:
1. public class a { 2. public void method1() { 3. try { 4. B b=new b(); 5. b.method2(); 6. // more code here 7. } catch (TestException te) { 8. throw new RuntimeException(te); 9. } 10. } 11. } 1. public class b { 2. public void method2() throws TestException { 3. // more code here 4. } 5. } 1. public class TestException extends Exception { 2. } Given: 31. public void method() { 32. A a=new a(); 33. a.method1(); 34. } Which is true if a TestException is thrown on line 3 of class b?()