1. Trang chủ
  2. » Giáo án - Bài giảng

Programming Exercises

6 125 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

PROGRAMMING EXERCISES 1. Given a design scenario, determine which collection classes and/or interfaces should be used to properly implement that design, including the use of the Comparable interface. 2. Write code that uses the generic versions of the Collections API, in particular, the Set, List, and Map interfaces and implementation classes. Recognize the limitations of the non-generic Collections API and how to refactor code to use the generic versions. 3. Develop code that makes proper use of type parameters in class/interface declarations, instance variables, method arguments, and return types; and write generic methods or methods that make use of wildcard types and understand the similarities and differences between these two approaches. 4. Use capabilities in the java.util package to write code to manipulate a list by sorting, performing a binary search, or converting the list to an array. Use capabilities in the java.util package to write code to manipulate an array by sorting, performing a binary search, or converting the array to a list. Use the java.util.Comparator and java.lang.Comparable interfaces to affect the sorting of lists and arrays. Furthermore, recognize the effect of the "natural ordering" of primitive wrapper classes and java.lang.String on sorting. 5. Write a method that takes a string and returns the number of unique characters in the string. It is expected that a string with the same character sequence may be passed several times to the method. Since the counting operation can be time consuming, the method should cache the results, so that when the method is given a string previously encountered, it will simply retrieve the stored result. Use collections and maps where appropriate. 6. Write a program which creates a concordance of characters occurring in a string (i.e., which characters occur where in a string). Read the string from the command line. Running the program: >java Concordance Hello World {d=[9], o=[4, 6], r=[7], W=[5], H=[0], l=[2, 3, 8], e=[1]} 7. Viết chương trình biểu diễn 1 danh sách liên kết. Các nút của danh sách này chứa thông tin về 1 sinh viên bao gồm mã số sv, họ tên, địa chỉ, email và 2 con trỏ chỉ đến nút kế tiếp(next) và nút trước nó (prev). Danh sách gồm 2 đối tượng First, Last chỉ đến phần tử đầu danh sách và cuối danh sách.Viết các phương thức cơ bản của 1 DSLK như chèn đầu, chèn cuối, xóa sinh viên có mã trùng với 1 mã sv cho trước, sắp xếp danh sách,… Viết chương trình chính để thử các chức năng vừa tạo. 8. Viết chương trình biểu diễn 1 từ điển trong máy tính. Gợi ý: Sử dụng TreeMap<String,WordObject> để lưu trữ tập các từ. Mỗi từ ở đây là 1 đối tượng gồm các thuộc tính: từ (khóa của đối tượng), phát âm, loại từ, ghi chú. Kết quả như hình

Ngày đăng: 13/05/2014, 11:15

TỪ KHÓA LIÊN QUAN

w