Lecture Introduction to Java programming - Chapter 14: Abstract classes and interfaces

You have learned how to write simple programs to create and display GUI components. Can you write the code to respond to user actions, such as clicking a button? In order to write such code, you have to know interfaces. An interface is for defining common behavior for classes (especially unrelated classes). Before discussing interfaces, we introduce a closely related subject: abstract classes. | Chapter 1 Introduction to Computers, Programs, and Java Chapter 14 Abstract Classes and Interfaces Motivations You learned how to write simple programs to display GUI components. Can you write the code to respond to user actions such as clicking a button? HandleEvent Run Objectives To design and use abstract classes (§). To process a calendar using the Calendar and GregorianCalendar classes (§). To specify common behavior for objects using interfaces (§). To define interfaces and define classes that implement interfaces (§). To define a natural order using the Comparable interface (§). To enable objects to listen for action events using the ActionListener interface (§). To make objects cloneable using the Cloneable interface (§). To explore the similarities and differences between an abstract class and an interface (§). To create objects for primitive values using the wrapper classes (Byte, Short, Integer, Long, Float, Double, Character, and Boolean) (§). To create a generic sort method (§). To simplify programming using automatic conversion between primitive types and wrapper class types (§). To use the BigInteger and BigDecimal classes for computing very large numbers with arbitrary precisions (§). To design the Rational class for defining the Rational type (§). Abstract Classes and Abstract Methods GeometricObject Circle Rectangle TestGometricObject Run abstract method in abstract class An abstract method cannot be contained in a nonabstract class. If a subclass of an abstract superclass does not implement all the abstract methods, the subclass must be defined abstract. In other words, in a nonabstract subclass extended from an abstract class, all the abstract methods must be implemented, even if they are not used in the subclass. object cannot be created from abstract class An abstract class cannot be instantiated using the new operator, but you can still . | Chapter 1 Introduction to Computers, Programs, and Java Chapter 14 Abstract Classes and Interfaces Motivations You learned how to write simple programs to display GUI components. Can you write the code to respond to user actions such as clicking a button? HandleEvent Run Objectives To design and use abstract classes (§). To process a calendar using the Calendar and GregorianCalendar classes (§). To specify common behavior for objects using interfaces (§). To define interfaces and define classes that implement interfaces (§). To define a natural order using the Comparable interface (§). To enable objects to listen for action events using the ActionListener interface (§). To make objects cloneable using the Cloneable interface (§). To explore the similarities and differences between an abstract class and an interface (§). To create objects for primitive values using the wrapper classes (Byte, Short, Integer, Long, Float, Double, .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.