Inheritance notes (Discussion 4) (Kế thừa trong Java) - Christine Zhou
- ページ数
- 1
- 形式
- DOCX
- サイズ
- 6.8 KB
- Trường
- University of California, Berkeley
- 閲覧数
- 0
- コメント
- 0
- Lượt tải
- 0
プレビューを生成中...
Tài liệu ghi chú về kế thừa trong Java, giải thích về ghi đè (overriding) và nạp chồng (overloading) phương thức, quy tắc chữ ký, kiểu trả về và phạm vi truy cập.
- ドキュメント名
- Inheritance notes (Discussion 4) (Kế thừa trong Java) - Christine Zhou
- 学校 / コース
- University of California, Berkeley · Lập trình Java
- 内容
- Tài liệu giải thích sự khác biệt giữa ghi đè và nạp chồng phương thức trong Java. Ghi đè yêu cầu chữ ký phương thức giống hệt, trong khi nạp chồng cho phép cùng tên nhưng khác tham số. Các vấn đề về kiểu trả về và bộ truy cập cũng được đề cập.
- 目次
- このドキュメントに明確な目次はありません。
- ページ数
- 1 ページ
- アップロード者
- Uni24h
説明
Trích nội dung tài liệu
Overriding and overloading Method overriding only occurs if the method signature is exactly the same. Let's take a look at the following classes: public class Bird { public void gulgate(Bird b) { ... } } public class Falcon { public void gulgate(Bird b) { ... } public void gulgate(Falcon f) { ... } } Here, Falcon::gulgate(Bird) overrides Bird::gulgate(Bird) since the method signatures are exactly the same. Falcon::gulgate(Falcon) is an example of method overloading, where the name of the function is the same but the argument that it takes in. Different return types If we had a method in Bird with the signature "public int gulgate(Falcon f)" (same signature as Falcon::gulgate(Falcon) but with a different return type), Java wouldn't allow this and would complain during compilation that the return types are not compatible (void from Falcon::gulgate(Falcon) and int from Bird::gulgate(Falcon)). Different access modifiers When the access modifiers are different, something slightly different will happen (I think this link describes it pretty well! Ctrl-F for "Overriding and Access-Modifiers") but don't worry about this too much since we haven't covered access modifiers in depth during lecture yet.
よくある質問
このドキュメントは無料ですか?
はい。「Inheritance notes (Discussion 4) (Kế thừa trong Java) - Christine Zhou」は無料です。ログインして「ダウンロード」をクリックするだけで、元のファイルを取得できます。
このドキュメントは何ページありますか?
このドキュメントは 1 ページあります(Lập trình Java コース用)。ダウンロードする前にオンラインでプレビューできます。
ダウンロードする前にプレビューできますか?
はい。このページにあるオンラインリーダーでドキュメントをプレビューし、その後ダウンロードするかどうかを決めることができます。
Inheritance notes (Discussion 4) (Kế thừa trong Java) - Christine Zhou
プレビューを生成中...
Trích nội dung tài liệu
Overriding and overloading Method overriding only occurs if the method signature is exactly the same. Let's take a look at the following classes: public class Bird { public void gulgate(Bird b) { ... } } public class Falcon { public void gulgate(Bird b) { ... } public void gulgate(Falcon f) { ... } } Here, Falcon::gulgate(Bird) overrides Bird::gulgate(Bird) since the method signatures are exactly the same. Falcon::gulgate(Falcon) is an example of method overloading, where the name of the function is the same but the argument that it takes in. Different return types If we had a method in Bird with the signature "public int gulgate(Falcon f)" (same signature as Falcon::gulgate(Falcon) but with a different return type), Java wouldn't allow this and would complain during compilation that the return types are not compatible (void from Falcon::gulgate(Falcon) and int from Bird::gulgate(Falcon)). Different access modifiers When the access modifiers are different, something slightly different will happen (I think this link describes it pretty well! Ctrl-F for "Overriding and Access-Modifiers") but don't worry about this too much since we haven't covered access modifiers in depth during lecture yet.
- ドキュメント名
- Inheritance notes (Discussion 4) (Kế thừa trong Java) - Christine Zhou
- 学校 / コース
- University of California, Berkeley · Lập trình Java
- 内容
- Tài liệu giải thích sự khác biệt giữa ghi đè và nạp chồng phương thức trong Java. Ghi đè yêu cầu chữ ký phương thức giống hệt, trong khi nạp chồng cho phép cùng tên nhưng khác tham số. Các vấn đề về kiểu trả về và bộ truy cập cũng được đề cập.
- 目次
- このドキュメントに明確な目次はありません。
- ページ数
- 1 ページ
- アップロード者
- Uni24h
コメント (0)
まだコメントはありません。最初のコメントを書きましょう!
Java DataBase Connectivity - Kết nối kho dữ liệu Java
Ôn tập lập trình Java (MT2 Review Solutions) - Ching and Christines
Asymptotics II, Search Trees (Discussion 7) (Kỹ thuật phân tích thời gian chạy, cây tìm kiếm nhị phân) - Christine Zhou
Introduction to Java (Discussion 1) (Giới thiệu về Java) - Christine Zhou
Giáo trình Lập trình Java
Tổng hợp Đề Toán 5 - Luyện thi vào Lớp 6 - CLB EMath
Bài giảng vật lý đại cương (Chương 3) - Đỗ Ngọc Uấn
Chương 8.Nguyên tử - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
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

コメント (0)
まだコメントはありません。最初のコメントを書きましょう!