O, b, j, e, c, t, s (Discussion 3) (Lập trình hướng đối tượng trong Java) - Christine Zhou
Tài liệu tóm tắt nội dung thảo luận về lập trình hướng đối tượng trong Java, bao gồm ôn tập static và non-static, mảng và các bài tập thực hành.
正在生成预览...
Discussion 3: {O, b, j, e, c, t, s} Christine Zhou Agenda Announcements Review: OOP and Static vs Non-Static Worksheet #2 Review: Arrays Worksheet #3 and #4 Worksheet #1 Announcements Project 0: 2048 is due 9/18, next Monday! Lab this week will partially be about the project HW2 is out and due 9/22, next Friday Get started early! Midterm 1 Conflict Form on Piazza due 9/15, this Friday MT1 is Wednesday, Sept 27 8-10PM Discussion survey: tinyurl.com/czdisc3 Review: Object Oriented Programming Class: define characteristics and behaviors of our object, act as a blueprint/template for our objects Can create instances of the object by using the constructor and the new keyword Human h = new Human(“Bob”, 1) “this” refers to the object that you are creating, like “self” in Python! public class Human { String name; int age; static int population; public Human(String name, int age) { this.name = name; this.age = age; population += 1; } public void greet() { System.out.println(“Hi! I’m ” + this.name) } public static void getPopulation() { System.out.println(population); } } Review: Object Oriented Programming Non-static (instance) variables and methods: Belong to the object itself Each person has their own name, age, and way to greet people Static (class) variables and methods: What is one static method that you’ve seen already? Belong to the class, no notion of “this” Preceded with “static” The “population” variable belongs to all Humans, not just one Human! public class Human { String name; int age; static int population; public Human(String name, int age) { this.name = name; this.age = age; population += 1; } public void greet() { System.out.println(“Hi! I’m ” + this.name) } public static void getPopulation() { System.out.println(population); } } Review: Object Oriented Programming Examples // In the Human class public class Human { public void testNonStatic(Human you) { greet(); this.greet(); you.greet(); Human.greet(); ge
… 下载原始文件以阅读完整文档。
- 文档名称
- O, b, j, e, c, t, s (Discussion 3) (Lập trình hướng đối tượng trong Java) - Christine Zhou
- 学校 / 课程
- University of California, Berkeley · Lập trình Java
- 内容
- Tài liệu này ôn lại các khái niệm cốt lõi của Lập trình hướng đối tượng như lớp, đối tượng, biến và phương thức tĩnh/không tĩnh, kèm theo các ví dụ minh họa và thông báo về bài tập, dự án.
- 目录
- Agenda
- Announcements
- Review: OOP and Static vs Non-Static
- Worksheet #2
- Review: Arrays
- Worksheet #3 and #4
- Worksheet #1
- 页数
- 17 页
- 上传者
- Giang Le
常见问题
此文档免费吗?
是的。“O, b, j, e, c, t, s (Discussion 3) (Lập trình hướng đối tượng trong Java) - Christine Zhou”是免费的 — 只需登录并点击“下载”即可获取原始文件。
这份文档有多少页?
该文档共有 17 页,适用于课程 Lập trình Java。您可以在下载前进行在线预览。
我可以在下载前预览吗?
是的。您可以通过在线阅读器直接在本页面预览此文档,然后再决定是否下载。

评论 (0)
暂无评论。快来抢沙发吧!