O, b, j, e, c, t, s (Discussion 3) (Lập trình hướng đối tượng trong Java) - Christine Zhou
Generating preview...
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.
Description
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
AI summary
- Document name
- O, b, j, e, c, t, s (Discussion 3) (Lập trình hướng đối tượng trong Java) - Christine Zhou
- School / Course
- University of California, Berkeley · Lập trình Java
- Content
- 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.
- Table of contents
- Agenda
- Announcements
- Review: OOP and Static vs Non-Static
- Worksheet #2
- Review: Arrays
- Worksheet #3 and #4
- Worksheet #1
- Pages
- 17 pages
- Uploaded by
- Uni24h
Frequently asked questions
Is this document free?
Yes. “O, b, j, e, c, t, s (Discussion 3) (Lập trình hướng đối tượng 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 17 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.
O, b, j, e, c, t, s (Discussion 3) (Lập trình hướng đối tượng trong Java) - Christine Zhou
Generating preview...
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
Read full document
- Document name
- O, b, j, e, c, t, s (Discussion 3) (Lập trình hướng đối tượng trong Java) - Christine Zhou
- School / Course
- University of California, Berkeley · Lập trình Java
- Content
- 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.
- Table of contents
- Agenda
- Announcements
- Review: OOP and Static vs Non-Static
- Worksheet #2
- Review: Arrays
- Worksheet #3 and #4
- Worksheet #1
- Pages
- 17 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!