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.
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
… Tải file gốc để đọc toàn bộ tài liệu.
- 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
- Doc.pages
- 17 pages
- Uploaded by
- Giang Le
Frequently asked questions
Tài liệu này có miễn phí không?
Có. “O, b, j, e, c, t, s (Discussion 3) (Lập trình hướng đối tượng trong Java) - Christine Zhou” miễn phí — bạn chỉ cần đăng nhập rồi bấm Tải xuống để lấy file gốc.
Tài liệu dài bao nhiêu trang?
Tài liệu gồm 17 trang, thuộc môn Lập trình Java. Bạn có thể xem trước online trước khi tải.
Tôi có thể xem trước trước khi tải không?
Có. Bạn xem trước tài liệu ngay trên trang này bằng trình đọc online, rồi quyết định tải về.

Comments (0)
No comments yet. Be the first!