5、若类Manager继承于类Employee,两个类中均定义了同名方法getDetails,现有语句“Employee e=new Manager();”,则程序中的e.getDetails()将导致()。A.调用类Manager的getDetails方法B.调用类Employee的getDetails方法C.先调用类Employee的getDetails方法,然后再调用Manager类的getDetails方法D.先调用类Manager的getDetails方法,然后再调用Employee类的getDetails方法

5、若类Manager继承于类Employee,两个类中均定义了同名方法getDetails,现有语句“Employee e=new Manager();”,则程序中的e.getDetails()将导致()。

A.调用类Manager的getDetails方法

B.调用类Employee的getDetails方法

C.先调用类Employee的getDetails方法,然后再调用Manager类的getDetails方法

D.先调用类Manager的getDetails方法,然后再调用Employee类的getDetails方法


参考答案和解析
Employee e=new Manager();

相关考题:

●以下关于类继承的说法中,错误的是(6)。(6)A.通过类继承,在程序中可以复用基类的代码B.在继承类中可以增加新代码C.在继承类中不能定义与被继承类(基类)中的方法同名的方法D.在继承类中可以覆盖被继承类(基类)中的方法

●试题五阅读下列程序说明,将应填入(n)处的字句写在答卷纸的对应栏内。【程序说明】对于一个公司的雇员来说,无非有3种:普通雇员、管理人员和主管。这些雇员有共同的数据:名字、每小时的工资,也有一些共同的操作:数据成员初始化、读雇员的数据成员及计算雇员的工资。但是,他们也有不同。例如,管理人员除有这些共同的特征外,有可能付固定薪水,主管除有管理人员的共同特征外,还有其他物质奖励等。3种雇员中,管理人员可以看作普通雇员的一种,而主管又可以看作管理人员的一种。我们很容易想到使用类继承来实现这个问题:普通雇员作为基类,管理人员类从普通雇员类中派生,而主管人员类又从管理人员类中派生。下面的程序1完成上述各个类的定义,并建立了3个雇员(一个普通雇员、一个管理人员和一个主管)的档案,并打印出各自的工资表。将"程序1"中的成员函数定义为内联函数,pay成员函数定义为虚函数,重新完成上述要求。【程序1】//普通雇员类class Employee{public:Employee(char*theName,float thePayRate);char*getName()const;float getPayRate()const;float pay(float hoursWorked)const;protected:char*name;//雇员名称float payRate;//薪水等级};Employee::Employee(char*theName,float thePayRate){name=theName;payRate=thePayRate;}char*Employee::getName() const{return name;}float Employee::getPayRate()const{return payRate;}float Employee::pay(float hoursWorked)const{return hoursWorked*payRate;}//管理人员类class Manager∶public Employee{public://isSalaried付薪方式:true付薪固定工资,false按小时付薪Manager(char*theName,float thePayRate,bool isSalaried);bool getSalaried()const;float pay(float hoursWorked)const;protected:bool salaried;};Manager::Manager(char*theName,float thePayRate,bool isSalaried)∶Employee(theName,thePayRate){salaried=isSalaried;}bool Manager::getSalaried() const{return salaried;}float Manager::pay(float hoursWorked)const{if(salaried)return payRate;/*else*/return Employee::pay(hoursWorked);}//主管人员类class Supervisor:public Employee{public:Supervisor(char*theName,float thePayRate,float theBouns):Employee(theName,thePayRate, (1) ),bouns(theBouns){}float getBouns()const{return bouns;}float pay(float hoursWorked)constreturn (2) ;}protected:float bouns;}#include"iostream.h"void main(){Employee e("Jack",50.00);Manager m("Tom",8000.00,true);Supervior s("Tanya",8000.00,8000.00);cout"Name:"e.getName()endl;cout"Pay:"e.pay(80)endl;//设每月工作80小时cout"Name:"m.getName()endl;cout"Pay:"m.pay (40) endl;cout"Name:"s.getName()endl;cout"Pay:"s.pay (40) endl;//参数40在这里不起作用}【程序2】#include"employee.h"//普通雇员类class Employee{public://构造函数Employee(string theName,float thePayRate):name(theName),payRate(thePayRate){}//取雇员姓名string getName() const{returnname;}//取雇员薪水等级float getPayRate()const{return payRate;}//计算雇员薪水virtual float pay(float hoursWorked)const{return (3) ;}protected:string name;//雇员名称float payRate;//薪水等级};//管理人员类//继承普通雇员类class Manager:public Employee{public://构造函数//isSalaried标识管理人员类的付薪方式//true 按阶段付薪(固定工资)//false按小时付薪Manager(string theName,float thePayRate,bool isSalaried):Employee(theName,thePayRate),salaried(isSalaried){}//取付薪方式bool getSalaried()const{return salaried;}//计算薪水virtual float pay(float (4) )const;protected:bool salaried;};float Manager::pay(float hoursWorked)const{if(salaried)//固定付薪方式return payRate;else//按小时付薪return (5) ; }//主管人员类class Supervisor: (6){public://构造函数Supervisor(string theName,float thePayRate,float theBouns):Manager(theName,thePayRate,true),bouns(theBouns){}//取奖金数额float getBouns()const{return bouns;}//计算薪水virtual float pay(float hoursWorked)const{retum payRate+bouns;}(7)float bouns;}#include"employee.h"#include"iostream.h"void main(){(8) *ep[3];ep[0]=new Employee("Jack","50.00");ep[1]=new Manager("Tom","8000.00",true);ep[2]=new Supervior("Tanya","8000.00","8000.00");for(int i=0;i3;i++){cout"Name:" (9) endl;cout"Pay:" (10) endl;//设每月工作80小时}}

Examine the data of the EMPLOYEES table.EMPLOYEES (EMPLOYEE_ID is the primary key. MGR_ID is the ID of managers and refers to the EMPLOYEE_ID)Which statement lists the ID, name, and salary of the employee, and the ID and name of the employee‘s manager, for all the employees who have a manager and earn more than 4000?()A.B.C.D.E.

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】设计希赛IT教育研发中心的工资管理系统,该中心主要有3类人员:经理、销售员和销售经理。要求存储这些人员的编号、姓名和月工资,计算月工资并显示全部信息。月工资计算办法是:经理拿固定月薪8000元;销售员拿固定工资1000元,然后再按当月销售额的4%提成;销售经理既拿固定月工资也领取销售提成,固定月工资为5000元,销售提成为所管辖部门当月销售总额的5‰。按要求设计一个基类employee,销售员类salesman,经理类manager,销售经理类 salesmanager。程序5-1是类employee的模块内容,程序5-2是类salesman的类模块内容,程序5-3是类manager的模块内容,程序5-4是类salesmanager的模块内容。在主测试程序中,输入张三所管部门月销售量10000后的输出结果如下:张三所管部门月销售量:10000销售经理:张三编号:1001本月工资:5050include <iostream.h>include <string.h>class employee{protected:int no;char *name;float salary;public:employee(int num,char *ch){ no=num;name=ch;salary=0; }virtual void pay()=0;virtual void display(){ cout<<"编号:"<<no<<endl;cout<<"本月工资:"<<salary<<endl; }};【程序5-2】class salesman: (1){protected:float commrate, sales;public:salesman(int num,char *ch):employee(num,ch){ commrate=0.04; }void pay(){ cout<<name<<"本月销售额:";cin>>saies;salary=sales*commrate+1000; }void display(){ cout<<"销售员:"<<name<<endl;employee::display(); }};【程序5-3】class manager: (1){protected:float monthpay;public:manager(int num,char *ch):employee(num,ch){ monthpay=8000; }void pay(){ salary=monthpay; }void display(){ cout<<"经理:"<<name<<endl;employee::display(); }};【程序5-4】class salesmanager: (2){public:salesmanager(int num,char *ch): (3){ monthpay=5000;commrate=0.005;}void pay(){ cout<<name<<"所管部门月销售量:";cin>>sales;(4) }void display(){ cout<<"销售经理:"<<name<<endl;(5) }};void main() //主测试函数{ salesmanager p1 (1001,"张三");p1.pay();p1.display();}

已知: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类

● 以下关于类继承的说法中,错误的是( )。A.通过类继承,在程序中可以复用基类的代码B.在继承类中可以增加新代码C.在继承类中不能定义与被继承类(基类)中的方法同名的方法D.在继承类中可以覆盖被继承类(基类)中的方法

阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。【说明】设计某IT教育研发中心的工资管理系统,该中心主要有3类人员:经理、销售员和销售经理。要求存储这些人员的编号、姓名和月工资,计算月工资并显示全部信息。月工资计算办法是:经理拿固定月薪8000元;销售员拿固定工资1000元,然后再按当月销售额的4%提成;销售经理既拿固定月工资也领取销售提成,固定月工资为5000元,销售提成为所管辖部门当月销售总额的5‰。按要求设计一个基类employee,销售员类salesman,经理类manager,销售经理类salesmanager.程序5-1是类employee的模块内容,程序5-2是类salesman的类模块内容,程序5-3是类manager的模块内容,程序5-4是类salesmanager的模块内容。在主测试程序中,输入张三所管部门月销售量10000后的输出结果如下:【程序5-1】#include#includeclassemployee{protected:intno;char*name;floatsalary;public:employee(intnum,char*ch){no=num;name=ch;salary=0;}virtualvoidpay()=0;virtualvoiddisplay(){cout《编号:《no《endl;cout《本月工资:《salary《endl;}};【程序5-2】classsalesman:(1){protected:floatcommrate,sales;public:salesman(intnum,char*ch):employee(num,ch){commrate=0.04;}voidpay(){cout《name《本月销售额:;cin》sales;salary=sales*commrate+1000;}voiddisplay(){cout《销售员:《name《endl;employee::display();}};【程序5-3】classmanager:(1){protected:floatmonthpay;public:manager(intnum,char*ch):employee(num,ch){monthpay=8000;}voidpay(){salary=monthpay;}voiddisplay(){cout《经理:《name《endl;employee::display();}};【程序5-4】classsalesmanager:(2){public:salesmanager(intnum,char*ch):(3){monthpay=5000;commrate=0.005;}voidpay(){cout《name《所管部门月销售量:;cin》sales;(4)}voiddisplay(){cout《销售经理:《name《endl;(5)}};voidmain()//主测试函数{salesmanagerp1(1001,张三);p1.pay();p1.display();}

使用VC6打开考生文件夹下的工程test18_3,此工程包含一个源程序文件test18_3.cpp,其中定义了用于表示雇员的类 Employee,但类Employee的定义并不完整。请按要求完成下列操作,将类Employee的定义补充完整。(1)补充类Employee的构造函数,请使用字符串函数将数据成员name,address,city,province和zipcode分别初始化为参数*nm,*addr,*city,*prov和*zip的值。请在注释“//**1**”之后添加适当的语句;(2)完成类Employee的成员函数ChangeName(char * newName)的定义,将newName指向的内容赋值给数据成员name,请在注释“//**2**”之后添加适当的语句;(3)完成类Employee的成员函数Display()的定义,先使用指针buffer动态申请一个char型的200单位大小的空间,然后使用字符串函数将数据成员name和address依次复制其中,最后返回该指针buffer,将请在注释“//**3**”之后添加适当的语句。输出结果如下:王东建国路大街105号注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。源程序文件test18_3.cpp清单如下:include <iostream.h>include <string.h>class Employee{protected:char name[20];char address[100];char city[20];char province[20];char zipcode[10];public:Employee(char *nm, char *addr,char *city, char *prov, char *zip);void ChangeName(char *newName);char *Display();};Employee::Employee(char *nm, char *adr, char *cit, char *prov, char *zip){//**1**strcpy(city, cit);strcpy(province,prov);strcpy(zipcode,zip);}void Employee::ChangeName(char * newName){//**2**}char *Employee::Display(){//**3**strcat(buffer, address);return buffer;}void main(){Employee emp("李华","建国路大街105号","石家庄","河北","103400");emp. ChangeName ("王东");cout<<emp.Display()<<end1;}

以下SQL99语句描述的是(26)。 CREATETYPE Employee( Name String, ssn integer); CREATE TYPE Manager UNDER Employee( Degree String, Dept String);A.关联关系B.嵌套关系C.继承类型D.聚集关系

已知类的继承关系如下:class Employee;class Manager extends Employeer;class Director extends Employee;则以下语句能通过编译的有哪些? A.Employee e=new Manager();B.Director d=new Manager();C.Director d=new Employee();D.Manager m=new Director();

Click the Exhibit button to examine the data of the EMPLOYEES table.Which statement lists the ID, name, and salary of the employee, and the ID and name of the employee‘s manager, for all the employees who have a manager and earn more than 4000?()A.SELECT employee_id Emp_id, emp_name Employee, salary, employee_id Mgr_id, emp_name Manager FROM employees WHERE salary 4000;B.SELECT e.employee_id Emp_id, e.emp_name Employee, e.salary, m.employee_id Mgr_id, m.emp_name Manager FROM employees e JOIN employees m WHERE e.mgr_id = m.mgr_id AND e.salary 4000;C.SELECT e.employee_id Emp_id, e.emp_name Employee, e.salary, m.employee_id Mgr_id, m.emp_name Manager FROM employees e JOIN employees m ON (e.mgr_id = m.employee_id) AND e.salary 4000;D.SELECT e.employee_id Emp_id, e.emp_name Employee, e.salary, m.mgr_id Mgr_id, m.emp_name Manager FROM employees e SELF JOIN employees m WHERE e.mgr_id = m.employee_id AND e.salary 4000;E.SELECT e.employee_id Emp_id, e.emp_name Employee, e.salary, m.mgr_id Mgr_id m.emp_name Manager FROM employees e JOIN employees m USING (e.employee_id = m.employee_id) AND e.salary 4000;

The manager is() of the new employee.A.suitableB.sufficientC.suspiciousD.superstitious

阅读下列说明,回答问题1至问题4,将解答填入答题纸的对应栏内。【说明】下图是某企业信息系统的一个类图,图中属性和方法前的"+"、"#"和"- " 分别表示公有成员、保护成员和私有成员。其中:(1)类Manager重新实现了类 Employee的方法 calSalary( ),类Manager中的方法querySalary( )继承了其父类Employee的方法querySalary( )。(2)创建类 Employee的对象时,给其设置职位(position)、基本工资(basicSalary)等信息。方法calSalary( ),根据个人的基本工资、当月工资天数(workDays)和奖金(bonus)等按特定规则计算员工工资。(3)类Department中的方法statSalary中首先调用了该类的方法load( ),获取本部门员工列表,然后调用了类 Employee中的方法calSalary( )。现拟采用面向对象的方法进行测试。【问题1】(5分)图4-1 所示的类图中,类manager 和类Employee之间是什么关系?该关系对测试的影响是什么?【问题2】(6分)1.类Manager重新实现了类 Employee的方法calSalary( ),这是面向对象的什么机制?是否需要重新测试该方法?2.类Manager中的方法querySalary( )继承了其父类 Employee 的方法querySalary( ),是否需要重新测试该方法?【问题3】(6分)1.请结合题干说明中的描述,给出测试类Employee 方法calSalary( )时的测试序列。2.请给出类图中各个类的测试顺序。【问题4】(3分)从面向对象多态特性考虑,测试方法statSalary( )时应注意什么?

【说明】下图是某学校信息系统的一个类图,图中属性和方法前的"+"、"#"和"- " 分别表示公有成员、保护成员和私有成员。其中:(1) 类Manager重新实现了类Student的方法 calScore( ),类Manager中的方法calWorkDays( )继承了其父类Employee的方法calWorkDays ( )。(2)创建类 Student的对象时,方法calStudent( ),根据每位同学的情况计算分数。(3)类Department中的方法statScore()中首先调用了该类的方法load( ),获取本班学生列表,然后调用了类 Student中的方法calScore( )。现拟采用面向对象的方法进行测试。 【问题1】(5分)图4-1 所示的类图中,类manager 和类Employee之间是什么关系?该关系对测试的影响是什么?【问题2】(6分)(1) 类Manager重新实现了类Student的方法calScore( ),这是面向对象的什么机制?是否需要重新测试该方法?(2) 类Manager中的方法calWorkDays ( )继承了其父类 Student 的方法calWorkDays ( ),是否需要重新测试该方法?【问题3】(6分)请给出类图中各个类的测试顺序。【问题4】(3分)从面向对象多态特性考虑,测试方法statScore( )时应注意什么?

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

以下关于类继承的说法中,错误的是()。A、通过类继承,在程序中可以复用基类的代码B、在继承类中可以增加新代码C、在继承类中不能定义与被继承类(基类)中的方法同名的方法D、在继承类中可以覆盖被继承类(基类)中的方法

在C#中,假设Person是一个类,而ITeller是一个接口,下面的()类声明是正确的。A、class Employee:Person,ITeller B、class Employee:ITeller,PersonC、class Employee-Person,ITellerD、class Employee:Person / ITeller

You created a view called EMP_DEPT_VU that contains three columns from the EMPLOYEES and DEPARTMENTS tables: EMPLOYEE_ID, EMPLOYEE_NAME AND DEPARTMENT_NAME. The DEPARTMENT_ID column of the EMPLOYEES table is the foreign key to the primary key DEPARTMENT_ID column of the DEPARTMENTS table. You want to modify the view by adding a fourth column, MANAGER_ID of NUMBER data type from the EMPLOYEES tables. How can you accomplish this task?()A、ALTER VIEW emp_dept_vu (ADD manager_id NUMBER);B、MODIFY VIEW emp_dept_vu (ADD manager_id NUMBER);C、ALTER VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employee e, departments d WHERE e.department_id = d.department_id;D、MODIFY VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department_id = d.department_id;E、CREATE OR REPLACE VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department_id = d.department_id;F、You must remove the existing view first, and then run the CREATE VIEW command with a new column list to modify a view.

单选题You created a view called EMP_DEPT_VU that contains three columns from the EMPLOYEES and DEPARTMENTS tables: EMPLOYEE_ID, EMPLOYEE_NAME AND DEPARTMENT_NAME. The DEPARTMENT_ID column of the EMPLOYEES table is the foreign key to the primary key DEPARTMENT_ID column of the DEPARTMENTS table. You want to modify the view by adding a fourth column, MANAGER_ID of NUMBER data type from the EMPLOYEES tables. How can you accomplish this task?()AALTER VIEW emp_dept_vu (ADD manager_id NUMBER);BMODIFY VIEW emp_dept_vu (ADD manager_id NUMBER);CALTER VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employee e, departments d WHERE e.department_id = d.department_id;DMODIFY VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department_id = d.department_id;ECREATE OR REPLACE VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department_id = d.department_id;FYou must remove the existing view first, and then run the CREATE VIEW command with a new column list to modify a view.

单选题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 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 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

单选题下列选项中,能实现对父类的getSalary方法重写的是(  )。class Employee{public double getSalary(){}}Aclass Manager extends Employee{public int getSalary(double x){}}Bclass Manager extends Employee{public double getSalary(int x,int y){}}Cclass Manager extends Employee{public double getSalary(){}}Dclass Manager extends Employee{public int getSalary(int x,int y){}}

单选题The manager showed the new employee _____ to find the supplies.AwhatBwhereCthatDwhich

单选题您已创建一个名为 CalcSalary,将确定 Certkiller.com 员工的薪酬类的责任。CalcSalary 类包括员工的薪酬递增和递减的方法。下面的代码包含在 CalcSalary 类中:()public class CalcSalary {// for promotionspublic static bool IncrementSalary (Employee Emp, double Amount){if (Emp.Status == QuarterlyReview.AboveGoals)Emp.Salary += Amount;return true;Apublic delegate bool Salary (Employee Emp, double Amount);Bpublic bool Salary (Employee Emp, double Amount);Cpublic event bool Salary (Employee Emp, double Amount);Dpublic delegate void Salary (Employee Emp, double Amount);

单选题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 编译错误