题目内容

设计雇员Employee类,记录雇员的情况,包括姓名、年薪、受雇时间,要求定义MyDate类作为受雇时间,其中包括工作的年、月、日,并用相应的方法对Employee类进行设置。编写测试类测试Employee类。要求使用自己的包。 mypackage.employee; class MyDate{ private int year; private int month; private int day; public MyDate(int year,int month,int day){ this.year=year; this.month=month; this.day=day; } public int getYear(){ return year; } } public class Employee{ private String name; private double salary; private MyDate hireDay; public Employee(String name,double salary,MyDate day){ this.name=name; this.salary=salary; hireDay=day; } public void print(){ System.out.println(name+ ""+salary+""+hireYear()); } public int hireYear(){ return hireDay.getYear(); } } class TestEmployee{ public static void main(String [] args){ Employee a=new Employee("李明",20000,new MyDate(2000,10,1)); Employee b=new Employee("王强",24000,new MyDate(1995,8,12));

A. print();
B. print(); } }

查看答案
更多问题

以下描述正确的是___。

A. JAVA不可以用来开发手机程序
B. 在JAVA程序中java.awt包是唯一自动引入的类库
C. java.io包是JAVA语言的输入输出类库
D. JAVA的包中可以有相同的类名

在Java中,关键字_____使类不能派生出子类。

A. final
B. public
C. volatile
D. native

下面___函数是public void aMethod(){...}的重载函数。

A. void aMethod( ){...}
B. public int aMethod(){...}
C. public void aMethod ( ){...}
D. public int aMethod ( int m){...}

Java是区分大小写的语言,关键字的大小写不能搞错,如果把类class写成Class或者CLASS,都是错误的。( )

答案查题题库