Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou
Generating preview...
Tài liệu thảo luận về kế thừa trong Java, bao gồm các khái niệm extends, interface, abstract class, static/dynamic types và bài tập ví dụ.
Description
Discussion 4: Inheritance Christine Zhou Agenda Announcements Review: Inheritance Problem 1 Review: More Inheritance Problem 2 Review: Static/Dynamic Types Problem 3 Announcements Office hours was crowded… Make sure to get started early and go to office hours earlier for help! Piazza questions: give us more information! What is the error that is being outputted? What have you tried to fix the error? Git-bug Proj0 due Monday 11:59PM See late policy on the course website HW2 due this Friday 11:59PM, go to OH early!! Guerrilla section planned for this weekend Saturday, 1-3PM in the labs Midterm next week on Wednesday 9/27 8-10PM Discussion survey: tinyurl.com/czdisc4 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() {...} } Review: Inheritance extends (can extend only one class) Inherits all instance variables and methods 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 Fish before making the Goldfish) constructor() { this.hello = 10; constructor() { super(); SAME! } this.hello = 10; } constructor() { this.hello = 10; DIFFERENT! } this.hello = 10; constructor() { super(10); Review: Inheritance public class Fish { String name; public Fish(String name) {...} Public void eat() {...} public void blink() {...} public class Goldfish extends Fish { public Goldfish(String name) { super(name); // need to have this! ... } public void eat() { print(“bloop”); super.eat(); } } } 1 Creating Cats Given the Animal class, fill in the definition of the Cat class so that it makes a "Meow!" noise when greet() is called. Assume this noise is all caps for kittens (less than 2 years old). How similar are Cats with Animals? How do we t
AI summary
- Document name
- Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou
- School / Course
- University of California, Berkeley · Lập trình Java
- Author (in document)
- Christine Zhou
- Content
- Tài liệu về kế thừa trong lập trình hướng đối tượng
- Table of contents
- Announcements
- Review: Inheritance
- Review: More Inheritance
- Review: Static/Dynamic Types
- Pages
- 19 pages
- Uploaded by
- Uni24h
Frequently asked questions
Is this document free?
Yes. “Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou” is free — just sign in and click Download to get the original file.
How many pages is this document?
The document has 19 pages, for the course Lập trình Java. You can preview it online before downloading.
Can I preview before downloading?
Yes. You can preview this document right on this page with the online reader, then decide whether to download.
Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou
Generating preview...
Discussion 4: Inheritance Christine Zhou Agenda Announcements Review: Inheritance Problem 1 Review: More Inheritance Problem 2 Review: Static/Dynamic Types Problem 3 Announcements Office hours was crowded… Make sure to get started early and go to office hours earlier for help! Piazza questions: give us more information! What is the error that is being outputted? What have you tried to fix the error? Git-bug Proj0 due Monday 11:59PM See late policy on the course website HW2 due this Friday 11:59PM, go to OH early!! Guerrilla section planned for this weekend Saturday, 1-3PM in the labs Midterm next week on Wednesday 9/27 8-10PM Discussion survey: tinyurl.com/czdisc4 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() {...} } Review: Inheritance extends (can extend only one class) Inherits all instance variables and methods 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 Fish before making the Goldfish) constructor() { this.hello = 10; constructor() { super(); SAME! } this.hello = 10; } constructor() { this.hello = 10; DIFFERENT! } this.hello = 10; constructor() { super(10); Review: Inheritance public class Fish { String name; public Fish(String name) {...} Public void eat() {...} public void blink() {...} public class Goldfish extends Fish { public Goldfish(String name) { super(name); // need to have this! ... } public void eat() { print(“bloop”); super.eat(); } } } 1 Creating Cats Given the Animal class, fill in the definition of the Cat class so that it makes a "Meow!" noise when greet() is called. Assume this noise is all caps for kittens (less than 2 years old). How similar are Cats with Animals? How do we t
Read full document
- Document name
- Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou
- School / Course
- University of California, Berkeley · Lập trình Java
- Author (in document)
- Christine Zhou
- Content
- Tài liệu về kế thừa trong lập trình hướng đối tượng
- Table of contents
- Announcements
- Review: Inheritance
- Review: More Inheritance
- Review: Static/Dynamic Types
- Pages
- 19 pages
- Uploaded by
- Uni24h
Comments (0)
No comments yet. Be the first!
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
Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou
Asymptotic Analysis (Discussion 7) (Phân tích tiệm cận) - Christine Zhou
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
Comments (0)
No comments yet. Be the first!