单选题public class Item {  private String desc;  public String getDescription() { return desc; }  public void setDescription(String d) { desc = d; } public static void modifyDesc(Item item, String desc) {  item = new Item();  item.setDescription(desc);  }  public static void main(String[] args) {  Item it = new Item();  it.setDescription(”Gobstopper”);  Item it2 = new Item();  it2.setDescription(”Fizzylifting”);  modifyDesc(it, “Scrumdiddlyumptious”);  System.out.println(it.getDescription());  System.out.println(it2.getDescription());  }  }  What is the outcome of the code? ()A Compilation fails.B Gobstopper  FizzyliftingC Gobstopper  ScrumdiddlyumptiousD Scrumdiddlyumptious FizzylifltngE Scrumdiddlyumptious Scrumdiddlyumptious

单选题
public class Item {  private String desc;  public String getDescription() { return desc; }  public void setDescription(String d) { desc = d; } public static void modifyDesc(Item item, String desc) {  item = new Item();  item.setDescription(desc);  }  public static void main(String[] args) {  Item it = new Item();  it.setDescription(”Gobstopper”);  Item it2 = new Item();  it2.setDescription(”Fizzylifting”);  modifyDesc(it, “Scrumdiddlyumptious”);  System.out.println(it.getDescription());  System.out.println(it2.getDescription());  }  }  What is the outcome of the code? ()
A

 Compilation fails.

B

 Gobstopper      Fizzylifting

C

 Gobstopper     Scrumdiddlyumptious

D

 Scrumdiddlyumptious     Fizzylifltng

E

 Scrumdiddlyumptious     Scrumdiddlyumptious


参考解析

解析: 暂无解析

相关考题:

为使下列代码正常运行,应该在下划线处填入的选项是abstract class Person{public Person(String n)!name=n;}public____String getDescription();public String getName(){return name;}private String name;}A.staticB.privateC.abstractD.final

阅读下列代码段 abstract class Person{ public Person(String n){ name=n; } public______String getDescription(); public String getName(){ } private String name; } 在下画线处应填入的修饰符是A.staticB.abstractC.protectedD.final

阅读下面代码 abstract class Person { public Person(String n) { name=n; } public______String getDescription(); public String getName() { return name; } private String name; } 在下画线处应填入的修饰符是A.staticB.abstractC.protectedD.final

Java代码查错1.abstract class Name {private String name;public abstract boolean isStupidName(String name) {}}大侠们,这有何错误?

为使下列代码正常运行,应该在下画线处填入的选项是( )。 abstract class person{ public Person(String n){ name=n: } Public String getDescription; public String getName{ return name; } private string name; }A.staticB.privateC.abstractD.final

阅读以下说明和Java代码,将应填入( )处的字句写在答题纸的对栏内。 【说明】 现如今线下支付系统可以使用现金(Cash)、移动支付、银行卡( Card)(信用卡( Creditcard)和储蓄卡( Debitcard))等多种支付方式( PaymentMethod)对物品(tem)账单(Bill)进行支付。图 5-1 是某支付系统的略类图。import java. util. Array List;import java. util. List;interface PaymentMethod { Public ( 1 )}∥cash、 Debitcard和ltem 实现略,ltem中getPrice( )取当前物品对象的价格abstract class Card (2) { private final String name, num; public Card(string name, String num){this.name= name; this, num = num; } @Overide public String toString ( ) { return String. format(“%s card[name = %s, num =%s}”, this. getType( ), name, num); @override public void pay(int cents) { System. out. printin(“Payed"+ cents+"cents using"+toString( )); this, execute Transaction(cents); } protected abstract String getType( ): protected abstract void execute Transaction(int cents)}class CreditCard ( 3 ) { public CreditCard(String name, String num){ (4) ;} @Override protected String getType( ){ return"CREDIT";} @Override protected void execute Transaction(int cents) { System. out. Println(cents +"paid using Credit Card. "); }} Class Bill {//包含所有购买商品的账单 private List items =new ArrayList( ); public void add(Item item) { items. add(item): } public intgetTotalPrice( ) {/*计算所有 item 的总价格,代码略*/} public void pay( PaymentMethod paymentMethod) {//用指定的支付方式完成支付(5) (getTotalPrice(): }}public class Paymentsystem { public void pay( ) { Bill bill =new Bill ( ); Item item1 = new Item(1234, 10); Item item2 new Item(“5678”, 40); Bill.add(item1); bill. add(item2);//将物品添加到账单中 Bill.pay(new Creditcard("LI SI”, "98765432101"))∥信用卡支付} public static void main(Stringl args) { (6) = new Paymentsystem( ); payment pay( ); }}

public class Pet{     private String name;     public Pet(){  System.out.print(1);    }  public Pet(String name){        System.out.print(2);    } }  public class Dog extends Pet{     public Dog(String name){        System.out.print(3);    } }  执行new Dog(“棕熊”);后程序输出是哪项?() A、 23B、 13C、 123D、 321

Which two allow the class Thing to be instantiated using new Thing()?A、 public class Thing { }B、 public class Thing { public Thing() {} }C、 public class Thing { public Thing(void) {} }D、 public class Thing { public Thing(String s) {} }E、 public class Thing { public void Thing() {} public Thing(String s) {} }

public class CreditCard {  private String cardlD;  private Integer limit;  public String ownerName;  public void setCardlnformation(String cardlD,  String ownerName, 28. Integer limit) {  this.cardlD = cardlD;  this.ownerName = ownerName;  this.limit = limit;  }  } Which is true?() A、 The class is fully encapsulated.B、 The code demonstrates polymorphism.C、 The ownerName variable breaks encapsulation.D、 The cardlD and limit variables break polymorphism.E、 The setCardlnformation method breaks encapsulation.

public class Employee{       private String name;  public Employee(String name){           this.name = name;      }  public String getName(){         return name;      } }  public class Manager extends Employee{       public Manager(String name){          System.out.println(getName());      } }  执行语句new Manager(“smith”)后程序的输出是哪项?() A、 smithB、 nullC、 编译错误D、 name

public class Employee{   private String name;   public Employee(String name){   this.name = name;  }   public void display(){   System.out.print(name);  }  }   public class Manager extends Employee{   private String department;   public Manager(String name,String department){   super(name);   this.department = department;  }   public void display(){   System.out.println( super.display()+”,”+department);  }   }   执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?() A、 smith,SALESB、 null,SALESC、 smith,nullD、 null,null

public class X {  public X aMethod() { return this;}  }  public class Y extends X {  }  Which two methods can be added to the definition of class Y?()A、 public void aMethod() {}B、 private void aMethod() {}C、 public void aMethod(String s) {}D、 private Y aMethod() { return null; }E、 public X aMethod() { return new Y(); }

public class Plant {  private String name;  public Plant(String name) { this.name = name; }  public String getName() { return name; }  }  public class Tree extends Plant {  public void growFruit() { }  public void dropLeaves() { }  }  Which is true?() A、 The code will compile without changes.B、 The code will compile if public Tree() { Plant(); } is added to the Tree class.C、 The code will compile if public Plant() { Tree(); } is added to the Plant class.D、 The code will compile if public Plant() { this(”fern”); } is added to the Plant class.E、 The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.

Given the following code:     1) class Parent {     2) private String name;     3) public Parent(){}     4) }  5) public class Child extends Parent {     6) private String department;  7) public Child() {}  8) public String getValue(){ return name; }     9) public static void main(String arg[]) {     10) Parent p = new Parent();     11) }  12) }  Which line will cause error?()   A、 line 3B、 line 6C、 line 7D、 line 8E、 line 10

public class Pet{     private String name;     public Pet(){  System.out.print(1);    }  public Pet(String name){        System.out.print(2);    } }  public class Dog extends Pet{     public Dog(){  System.out.print(4);    }  public Dog(String name){        this();  System.out.print(3);    } }  执行new Dog(“棕熊”);后程序输出是哪项?()  A、 143B、 423C、 243D、 1134

单选题public class Employee{       private String name;  public Employee(String name){           this.name = name;      }  public void display(){         System.out.print(name);      } }  public class Manager extends Employee{       private String department;  public Manager(String name,String department){          super(name);  this.department = department;  }  public void display(){  System.out.println(super.display()+”,”+department);      } }  执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A smith,SALESB null,SALESC smith,nullD null,nullE 编译错误

单选题public class Item {  private String desc;  public String getDescription() { return desc; }  public void setDescription(String d) { desc = d; } public static void modifyDesc(Item item, String desc) {  item = new Item();  item.setDescription(desc);  }  public static void main(String[] args) {  Item it = new Item();  it.setDescription(”Gobstopper”);  Item it2 = new Item();  it2.setDescription(”Fizzylifting”);  modifyDesc(it, “Scrumdiddlyumptious”);  System.out.println(it.getDescription());  System.out.println(it2.getDescription());  }  }  What is the outcome of the code? ()A Compilation fails.B Gobstopper  FizzyliftingC Gobstopper  ScrumdiddlyumptiousD Scrumdiddlyumptious FizzylifltngE Scrumdiddlyumptious Scrumdiddlyumptious

单选题public class Pet{   private String name;   public Pet(){   System.out.print(1);  }   public Pet(String name){   System.out.print(2);  }  }   public class Dog extends Pet{  public Dog(){   System.out.print(4);  }   public Dog(String name){   super(name);   System.out.print(3);  }   }   执行new Dog(“棕熊”);后程序输出是哪项?()A 33B 13C 23D 123

单选题public class Employee{       private String name;  public Employee(String name){           this.name = name;      }  public String getName(){         return name;      } }  public class Manager extends Employee{       private String department;  public Manager(String name,String department){          this.department = department;          super(name);  System.out.println(getName());      }  }  执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A smithB nullC SALESD 编译错误

单选题public class Pet{     private String name;     public Pet(){  System.out.print(1);    }  public Pet(String name){        System.out.print(2);    } }  public class Dog extends Pet{     public Dog(String name){        System.out.print(3);    } }  执行new Dog(“棕熊”);后程序输出是哪项?()A 23B 13C 123D 321

单选题public class CreditCard {  private String cardlD;  private Integer limit;  public String ownerName;  public void setCardlnformation(String cardlD,  String ownerName, 28. Integer limit) {  this.cardlD = cardlD;  this.ownerName = ownerName;  this.limit = limit;  }  } Which is true?()A The class is fully encapsulated.B The code demonstrates polymorphism.C The ownerName variable breaks encapsulation.D The cardlD and limit variables break polymorphism.E The setCardlnformation method breaks encapsulation.

单选题public class Employee{   private String name;   public Employee(String name){   this.name = name;  }   public String getName(){   return name;  }  }   public class Manager extends Employee{   public Manager(String name){   System.out.println(getName());  }  }   执行语句new Manager(“smith”)后程序的输出是哪项?()A smithB nullC 编译错误D name

多选题public class NamedCounter {  private final String name;  private int count;  public NamedCounter(String name) { this.name = name; }  public String getName() { return name; }  public void increment() { coount++; }  public int getCount() { return count; } public void reset() { count = 0; } }  Which three changes should be made to adapt this class to be used safely by multiple threads? ()Adeclare reset() using the synchronized keywordBdeclare getName() using the synchronized keywordCdeclare getCount() using the synchronized keywordDdeclare the constructor using the synchronized keywordEdeclare increment() using the synchronized keyword

单选题public class Plant {  private String name;  public Plant(String name) { this.name = name; }  public String getName() { return name; }  }  public class Tree extends Plant {  public void growFruit() { }  public void dropLeaves() { }  }  Which is true?()A The code will compile without changes.B The code will compile if public Tree() { Plant(); } is added to the Tree class.C The code will compile if public Plant() { Tree(); } is added to the Plant class.D The code will compile if public Plant() { this(”fern”); } is added to the Plant class.E The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.

单选题Given the following code:     1) class Parent {     2) private String name;     3) public Parent(){}     4) }  5) public class Child extends Parent {     6) private String department;  7) public Child() {}  8) public String getValue(){ return name; }     9) public static void main(String arg[]) {     10) Parent p = new Parent();     11) }  12) }  Which line will cause error?()A line 3B line 6C line 7D line 8E line 10

单选题public class Employee{   private String name;   public Employee(String name){   this.name = name;  }   public void display(){   System.out.print(name);  }  }   public class Manager extends Employee{   private String department;   public Manager(String name,String department){   super(name);   this.department = department;  }   public void display(){   System.out.println( super.display()+”,”+department);  }   }   执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A smith,SALESB null,SALESC smith,nullD null,null

单选题public class Employee{   private String name;   public Employee(String name){   this.name = name;  }   public String getName(){   return name;  }  }   public class Manager extends Employee{   private String department;   public Manager(String name,String department){   this.department = department;   super(name); (应于上一行掉位置)   System.out.println(getName());  }  }   Super的位置是否在方法的首行   执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A smithB nullC SALESD 编译错误

多选题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?()Ainsert a call to this() in the Car constructorBinsert a call to this() in the MeGo constructorCinsert a call to super() in the MeGo constructorDinsert a call to super(vin) in the MeGo constructorEchange the wheelCount variable in Car to protectedFchange line 3 in the MeGo class to super.wheelCount = 3;