Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou
正在生成预览...
Tài liệu hướng dẫn buổi thảo luận số 4 về kế thừa trong Java, bao gồm ôn tập kế thừa, kiểm thử JUnit và các bài tập thực hành.
描述
Discussion 4: Inheritance Disclaimer There will be a lot of “Java rules” for the next week or so; bear with us! Agenda Problem 1 Mini lecture and Problem 2 Mini lecture and Problem 3 Problem 4 at your own pace Administrivia Project 1B and 1Gold released, due Saturday 2/16 Lab this week is peer-code review; attendance is required! Midterm 2/20, 8-10 PM, see midterm post for more details Room assignments out later on Guerrilla section this Sunday 2/17 from 2-4pm in 271, 273, 275 Soda One-on-one tutoring sign ups on Piazza weekly Resources: tinyurl.com/cz-disc4-sp19 Resources: tinyurl.com/cs61b-christine-zhou JUnit Testing What are the advantages and disadvantages of writing JUnit tests? Advantages: 1. Organized code - each test corresponds to different part of program 2. Can debug code locally 3. Documentation that your program works 4. Can reduce the amount of test code you need to write because you can reuse code Disadvantages: 1. Hard to use for higher-level testing (integration testing) Review: Inheritance public class Fish { String name; public Fish(String name) {...} public class Goldfish { String name; public Goldfish(String name) {...} Public void eat() {...} public void blink() {...} public void eat() { print(“bloop”); ... } } public void blink() {...} } Inheritance: extends extends (can extend only one class) Inherits all fields, methods, and nested classes Constructor is not inherited, but there will be an implicit call to super( ) in the beginning of the subclass’s constructor (need to make the Superclass before making the Subclass) If the Superclass’s constructor requires arguments, you must write an explicit call to super! Fish() { Goldfish() { this.name = “Bob”; super(); this.age = 12; this.name = “Bobfish”; } } Fish(String name) { Goldfish(String name) { this.name = name; super(name); this.age = 12; this.name
AI 摘要
- 文档名称
- Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou
- 学校 / 课程
- University of California, Berkeley · Lập trình Java
- 内容
- Tài liệu thảo luận về kế thừa trong Java, bao gồm kiểm thử JUnit, cú pháp 'extends' và 'implements', cũng như sự khác biệt giữa kiểu tĩnh và động. Nội dung được trình bày qua các vấn đề, bài giảng nhỏ và ví dụ minh họa.
- 目录
- Discussion 4: Inheritance
- Disclaimer
- Agenda
- Administrivia
- JUnit Testing
- Review: Inheritance
- Inheritance: extends
- Review: Inheritance
- Creating Cats
- Creating Cats
- Review: More Inheritance
- Inheritance: implements
- Review: Static vs. Dynamic Types
- Overriding/Overloading
- 页数
- 27 页
- 上传者
- Uni24h
常见问题
此文档免费吗?
是的。“Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou”是免费的 — 只需登录并点击“下载”即可获取原始文件。
这份文档有多少页?
该文档共有 27 页,适用于课程 Lập trình Java。您可以在下载前进行在线预览。
我可以在下载前预览吗?
是的。您可以通过在线阅读器直接在本页面预览此文档,然后再决定是否下载。
Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou
正在生成预览...
Discussion 4: Inheritance Disclaimer There will be a lot of “Java rules” for the next week or so; bear with us! Agenda Problem 1 Mini lecture and Problem 2 Mini lecture and Problem 3 Problem 4 at your own pace Administrivia Project 1B and 1Gold released, due Saturday 2/16 Lab this week is peer-code review; attendance is required! Midterm 2/20, 8-10 PM, see midterm post for more details Room assignments out later on Guerrilla section this Sunday 2/17 from 2-4pm in 271, 273, 275 Soda One-on-one tutoring sign ups on Piazza weekly Resources: tinyurl.com/cz-disc4-sp19 Resources: tinyurl.com/cs61b-christine-zhou JUnit Testing What are the advantages and disadvantages of writing JUnit tests? Advantages: 1. Organized code - each test corresponds to different part of program 2. Can debug code locally 3. Documentation that your program works 4. Can reduce the amount of test code you need to write because you can reuse code Disadvantages: 1. Hard to use for higher-level testing (integration testing) Review: Inheritance public class Fish { String name; public Fish(String name) {...} public class Goldfish { String name; public Goldfish(String name) {...} Public void eat() {...} public void blink() {...} public void eat() { print(“bloop”); ... } } public void blink() {...} } Inheritance: extends extends (can extend only one class) Inherits all fields, methods, and nested classes Constructor is not inherited, but there will be an implicit call to super( ) in the beginning of the subclass’s constructor (need to make the Superclass before making the Subclass) If the Superclass’s constructor requires arguments, you must write an explicit call to super! Fish() { Goldfish() { this.name = “Bob”; super(); this.age = 12; this.name = “Bobfish”; } } Fish(String name) { Goldfish(String name) { this.name = name; super(name); this.age = 12; this.name
阅读全文
- 文档名称
- Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou
- 学校 / 课程
- University of California, Berkeley · Lập trình Java
- 内容
- Tài liệu thảo luận về kế thừa trong Java, bao gồm kiểm thử JUnit, cú pháp 'extends' và 'implements', cũng như sự khác biệt giữa kiểu tĩnh và động. Nội dung được trình bày qua các vấn đề, bài giảng nhỏ và ví dụ minh họa.
- 目录
- Discussion 4: Inheritance
- Disclaimer
- Agenda
- Administrivia
- JUnit Testing
- Review: Inheritance
- Inheritance: extends
- Review: Inheritance
- Creating Cats
- Creating Cats
- Review: More Inheritance
- Inheritance: implements
- Review: Static vs. Dynamic Types
- Overriding/Overloading
- 页数
- 27 页
- 上传者
- Uni24h
评论 (0)
暂无评论。快来抢沙发吧!
Java DataBase Connectivity - Kết nối kho dữ liệu Java
Asymptotic Analysis (Discussion 7) (Phân tích tiệm cận) - Christine Zhou
Misc.onclusion (Discussion 14-END) (Ôn tập cấu trúc dữ liệu) - Christine Zhou
Final Review Solutions (Cấu trúc dữ liệu heap, hàng đợi ưu tiên và duyệt đồ thị) - Ching and Christines
Giáo trình Lập trình Java
Chương 7.Cơ học lượng tử - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 6.Quang học lượng tử - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 5.Thuyết tương đối - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 4. Tán xạ ánh sáng - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 3.Phân cực ánh sáng - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
评论 (0)
暂无评论。快来抢沙发吧!