package AbstractTest;import java.util.Scanner;public class PayrollSystem { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("请输入当月月份"); int m = sc.nextInt(); Employee[] emps = new Employee[2]; emps[0] = new SalariedEmployee("麻蛇", 1002, new MyDate(1990, 10, 10),1000); emps[1] = new HourlyEmployee("草泥马", 2200, new MyDate(1993, 5, 4), 60, 240); for (int i = 0; i < emps.length; i++) { System.out.println(emps[i]); double money = emps[i].earnings(); if (m == emps[i].getBirthday().getMonth()) { money += 100; System.out.println("生日快乐,奖励一百元!"); } System.out.println("月工资为: " + emps[i].earnings()); } }}//InterviewTestpackage Test1;public class InterviewTest1 { public static void main(String[] args) { base1 b = new base1(); b.add(1, 2, 3); //correct! base1 b2= new Sub1(); b2.add(1,2,3); //Yes! Sub1 s = (Sub1) b2; s.add(1,2,3); //No! }}class base1 { public void add(int a, int..、arr) { System.out.println("correct!"); }}class Sub1 extends base1 { public void add(int a, int[] arr) { System.out.println("Yes!"); } public void add(int a, int b, int c) { System.out.println("No!"); }}//拆包package Test1;import java.util.Scanner;import java.util.Vector;import static java.lang.System.*;public class ScoreTest { public static void main(String[] args) { Scanner scan = new Scanner(System.in); Vector v = new Vector(); int maxScore = 0; while (true) { out.println("请输入学生成绩(输入负数表示退出)"); int nextScore = scan.nextInt(); if (nextScore < 0) { break; } else if (nextScore > 100) { out.println("学生成绩不能超过100"); continue; } else { Integer p = Integer.valueOf(nextScore); v.addElement(p); maxScore = Math.max(maxScore, nextScore); } } char grade; for (int i = 0; i < v.size(); i++) { Object obj = v.elementAt(i); //自动拆包 //int cur = (Integer)obj; //包装转基本数据 Integer cur1 = (Integer)obj; int cur = cur1.intValue(); int diff = maxScore - cur; if (diff < 10) { grade = 'A'; } else if (diff >= 10 && diff < 20) { grade = 'B'; } else if (diff >= 20 && diff < 30) { grade = 'C'; } else { grade = 'D'; } out.println("Student " + i + " score is " + cur + " and grade is " + grade); } }}
关键字static:
关键字Final:
抽象Abstract
接口Interface…