public class Employee

题目

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、 smith
  • B、 null
  • C、 编译错误
  • D、 name
参考答案和解析
正确答案:C
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

interface Data { public void load(); }  abstract class Info { public abstract void load(); }  Which class correctly uses the Data interface and Info class?() 

  • A、 public class Employee extends Info implements Data { public void load() { /*do something*/ } }
  • B、 public class Employee implements Info extends Data { public void load() { /*do something*/ } }
  • C、 public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
  • D、 public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
  • E、 public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
  • F、 public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }

正确答案:A

第2题:

10. abstract public class Employee {  11. protected abstract double getSalesAmount();  12. public double getCommision() {  13. return getSalesAmount() * 0.15;  14. }  15. }  16. class Sales extends Employee {  17. // insert method here  18. }  Which two methods, inserted independently at line 17, correctly complete the Sales class?()

  • A、 double getSalesAmount() { return 1230.45; }
  • B、 public double getSalesAmount() { return 1230.45; }
  • C、 private double getSalesAmount() { return 1230.45; }
  • D、 protected double getSalesAmount() { return 1230.45; }

正确答案:B,D

第3题:

已知:Manager extends Employee观察:public Manager(String n,double s,int year,int month,int day) { super(n,s,year,month,day); bonus=0; }其中super是 ( )

A.Object类

B.Manager类

C.Employee类

D.Class类


正确答案:C
解析:本题中有extends这说明是继承,子类Manager继承父类Employee,使用变量super能够实现对父类成员的访问,所以本题中super指的是父类Employee。

第4题:

Which the two demonstrate an “is a” relationship?()

  • A、 public interface Person {}  Public class Employee extends Person {}
  • B、 public interface Shape {}  public interface Rectangle extends Shape {}
  • C、 public interface Color {}  public class Shape { private Color color; }
  • D、 public class Species {}  public class Animal { private Species species; }
  • E、 interface Component {} Class Container implements Component {private Component [] children;

正确答案:B,E

第5题:

在C#中,假设Person是一个类,而ITeller是一个接口,下面的()类声明是正确的。

  • A、class Employee:Person,ITeller 
  • B、class Employee:ITeller,Person
  • C、class Employee-Person,ITeller
  • D、class Employee:Person / ITeller

正确答案:A

第6题:

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) {} }

正确答案:A,B

第7题:

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,SALES
  • B、 null,SALES
  • C、 smith,null
  • D、 null,null

正确答案:A

第8题:

Which three demonstrate an “is a” relationship?() 

  • A、 public class X {  }     public class Y extends X { }
  • B、 public interface Shape { }     public interface Rectangle extends Shape{ }
  • C、 public interface Color { }     public class Shape { private Color color; }
  • D、 public interface Species { }     public class Animal { private Species species; }
  • E、 public class Person { }    public class Employee {      public Employee(Person person) { }
  • F、 interface Component { }     class Container implements Component {   private Component[] children; }

正确答案:A,B,F

第9题:

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

  • A、 public class Employee implements Info extends Data { public void load(){/*dosomething*/}     }
  • B、public class Employee extends Inf.implements Data{ public void load() {/*do something*/}     }
  • C、public class Empl.yee implements Inf extends Data{ public void Data.1oad(){* do something*/}     public void load(){/*do something*/}     }
  • D、public class Employee extends Inf implements Data  {  public void Data.1oad()  {/*do something*/)     public void info.1oad(){/*do something*/}    }

正确答案:B

第10题:

Which two demonstrate an “is a” relationship?()   

  • A、 public interface Person { }  public class Employee extends Person { }
  • B、 public interface Shape { }  public class Employee extends Shape { }
  • C、 public interface Color { }  public class Employee extends Color { }
  • D、 public class Species { }  public class Animal (private Species species;)
  • E、 interface Component { }  Class Container implements Component ( Private Component[ ] children;  )

正确答案:D,E

更多相关问题