《模拟试题2-参考答案(3页).doc》由会员分享,可在线阅读,更多相关《模拟试题2-参考答案(3页).doc(3页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、-模拟试题2-参考答案-第 - 3 - 页Java语言程序设计模拟试题二答案一、选择题(152分)题号12345678910答案BA CC BBCADC题号11121314151617181920答案ABDBDCADDA二、填空题:共10小题,共20空 ,每空1分 ,满分20分;请将答案填入横线上。1max=xy?x:y;)2(long var=10000000000L;或long var=(long)1e10;)3(float 32位、double 64位)4顺序结构 、选择结构、循环结构5(return a*b)687属性8(属性、方法、类)9(类、方法)10继承、封装、多态三、程序阅读题
2、:共5小题,满分20分。 1(i j k l) (i j)2 B b=new B(10,A);b.show();3Hello, Java world!Hello, students! 4 (张山;30;3800.0)(2)5 no jobkids should not work四、程序填空题:共5小题,每小题4分,满分20分。1 0 continue 2 Myclass int j3 max(i1,i2,i3)static4 interface abstract 5 Applet或JApplet,drawString五、程序设计题:满分20分。【问题一】 5分abstract class Pe
3、rson private String name; public Person(String n) name = n; public abstract String getDescription(); public String getName() return name;【问题二】 5分class Employee extends Personprivate double salary; public Employee(String name, double salary) super(name); this.salary = salary; public double getSalary(
4、) return salary; public String getDescription() return an employee with a salary of + salary; public void raiseSalary(double byPercent) double raise = salary * byPercent / 100; salary += raise;【问题三】 5分class Student extends Personprivate String major; public Student(String name, String major) super(n
5、ame); this.major = major; public String getDescription() return a student majoring in + major;【问题四】 5分public class PersonTest public static void main(String args) Person people = new Person2;/定义一个Person数组:people; /向数组people中加入Student和Employee对象 people0= new Employee(Harry Hacker, 50000); people1= new Student(Maria Morris, computer science); for(int i=0;ipeople.length;i+) System.out.println(peoplei.getName() + , + peoplei.getDescription();