Câu 1: chọn "lớp con có thể khai báo biến chưa có trên lớp cha". Câu 2: viết thử 1 chương trình có biến mang thuộc tính private static rồi thử xem cái nào lỗi. Mã: package untitled1; class Assembly { /* Instance Variables */ private String name; private Date today; private int discount; //define instance variables named parta, partb, partc private Part part1; private Part part2; private Part part3; public Assembly(String assemblyName, int m, int d, int y, int percentage, Part partA , Part partB , Part partC ) { name = assemblyName; today = new Date(m, d, y); discount = percentage; part1 = partA; part2 = partB; part3 = partC; } public int price() { /*Return my total un-discounted price in dollars.*/ return part1.price() + part2.price() + part3.price(); } public int discountedPrice() { /*Return my discounted price in dollars.*/ double price; price = price() * (1 - discount); return (int)(price); } public void display() { System.out.println(name); //display name System.out.print("\tAssembled on"); System.out.println(today); //display date System.out.println("\tConsists of"); System.out.print("\t"); this.part1.display(); System.out.print("\t"); this.part2.display(); System.out.print("\t"); this.part3.display(); System.out.print("\tTotal $"); System.out.println(price()); //display price System.out.print("Discount "); System.out.print(discount); //display discount System.out.println("%"); System.out.print("Discounted price $"); System.out.println(discountedPrice()); //display discounted price } } class Part { private String name; private int price; public Part(String partName, int value) { name = partName; price = value; } public void display() { /*Display part name*/ System.out.print(name); System.out.print(" $"); /*Display part price*/ System.out.println(price); } public int price() { return price; } } class Date { private int month; // 1-12 private int day; // 1-31 based on month private int year; // any year //Constructor public Date(int mn, int dy, int yr) { month = mn; day = dy; year = yr; } // Create a String of the form month/day/year public String toString() { return month + "/" + day + "/" + year; } } class Test { //Test the Assembly and Parts classes by creating an assembly and displaying it. public static void main(String args[]) { /*Create the 3 part objects part1, part2, part3, create the an assembly object that contains them and display the assembly. */ //Create object part1 with the values "Engine", 6000 Part partA = new Part("Engine", 6000); //(Create object part2 with the values"Frame", 7000; Part partB = new Part("Frame", 7000); //Create object part3 with the values"Interior", 4000; Part partC = new Part("Interior", 4000); //Create object assembly with the values"Automobile", 12,1,2006, 10, part1, part2, part3; Assembly assembly = new Assembly("Automobile", 12, 1, 2006, 10, partA, partB, partC); assembly.display(); } } Lớp lưu trữ các thông tin của sự kiện action. http://java.sun.com/docs/books/tutorial/java/javaOO/thiskey.html You can declare a variable in any scope to be final. The value of a final variable cannot change after it has been initialized. Such variables are similar to constants in other programming languages. To declare a final variable, use the final keyword in the variable declaration before the type. final int aFinalVar = 0; The previous statement declares a final variable and initializes it all at once. Subsequent attempts to assign a value to aFinalVar result in a compiler error. You may, if necessary, defer initialization of a final local variable. Simply declare the local variable and initialize it later, as follows. final int blankfinal; . . . blankfinal = 0; A final local variable that has been declared but not yet initialized is called a blank final. Again, once a final local variable has been initialized, it cannot be set, and any later attempts to assign a value to blankfinal result in a compile-time error.