TAILIEUCHUNG - Lecture An Introduction to Object-Oriented Programming with Java (4/e): Chapter 4 - C. Thomas Wu

Chapter 4 (part 1) - Defining your own classes. After you have read and studied this chapter, you should be able to: Define a class with multiple methods and data members, differentiate the local and instance variables, define and use value-returning methods, distinguish private and public methods, distinguish private and public data members, pass both primitive data and objects to a method. | Chapter 4 Defining Your Own Classes Part 1 4th Ed Chapter 4 - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Objectives After you have read and studied this chapter, you should be able to Define a class with multiple methods and data members Differentiate the local and instance variables Define and use value-returning methods Distinguish private and public methods Distinguish private and public data members Pass both primitive data and objects to a method 4th Ed Chapter 4 - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Why Programmer-Defined Classes Using just the String, GregorianCalendar, JFrame and other standard classes will not meet all of our needs. We need to be able to define our own classes customized for our applications. Learning how to define our own classes is the first step toward mastering the skills necessary in building large programs. Classes we define ourselves are called programmer-defined classes. 4th Ed Chapter 4 - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The sample application programs we have written so far included only one class, the main class of the program. And the main class contained only one method, the main method. When we review the sample programs developed so far, we note two key characteristics: The programs included only one class, the main class of the program. The main class contained only one method, the main method. From this main method, we used objects and classes from the standard packages such as and . Such organization works only for small programs. In order to manage complexity of large programs, it is best to define instantiable classes. First Example: Using the Bicycle Class class BicycleRegistration { public static void main(String[] args) { Bicycle bike1, bike2; String owner1, owner2; bike1 = new Bicycle( ); //Create and assign values to bike1 ("Adam .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.