Lecture Java programming language: Classes and Object-Oriented Development - Ho Dac Hung
Số trang: 10
Loại file: pdf
Dung lượng: 145.23 KB
Lượt xem: 5
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Lecture Java programming language: Classes and Object-Oriented Development mentions about what is an object?, designing and writing a class, writing constructors, instance and class members, the object class, classes using classes, object-oriented development.
Nội dung trích xuất từ tài liệu:
Lecture Java programming language: Classes and Object-Oriented Development - Ho Dac Hung Classes and Object-Oriented Development Ho Dac Hung1 What is an Object? In object-oriented programming, an object stores data and can perform actions and provide communication. The state of an object refers to the data it stores. The behavior of an object is defined by the action and communication it provides.2 What is an Object? An object is an instance of a class, A class is a data type that defines variables for the state of an object and method for an object’s behavior.3 Designing and Writing a Class Designing a class requires choosing the data the object will store and determining the actions and communication the object will provide. The design should include variable names and method names along with a description of the method and any required parameters.4 Designing and Writing a Class A class is written in a separate file and consists of a declaration and a body. The class declaration includes the access level, the keyword class, and the class name. The class body contains variables, constructors, and methods. A class takes the form: class { }5 Writing Constructors A constructor of a class is automatically executed when object is instantiated. Once an object is instantiated, the method members of the class can be called in any order. Unexpected results may occur if an accessor method is called before a member variable has been set to a valid value. To prevent this, variables should be initialized in the constructor. public (){ }6 Instance and Class Members Each object, or instance, of a class has its own copy of variables called instance variables. A class may also contain class variables. A class variables is declared with the keyword static and only one copy is maintained for all objects to refer to.7 The Object Class The Object class is the superclass of all other classes.8 Classes Using Classes A cless may contain member variables that are class data types. Complex data can be easily represented in this way. A class that contains class member variables demonstrates a has-a relationship.9 Object-Oriented Development Object-oriented programming requires that the solution to a task be implemented as a system of objects. In this system, objects communicate with other objects to provide a solution to the task. This approach to creat software is called object- oriented development.10
Nội dung trích xuất từ tài liệu:
Lecture Java programming language: Classes and Object-Oriented Development - Ho Dac Hung Classes and Object-Oriented Development Ho Dac Hung1 What is an Object? In object-oriented programming, an object stores data and can perform actions and provide communication. The state of an object refers to the data it stores. The behavior of an object is defined by the action and communication it provides.2 What is an Object? An object is an instance of a class, A class is a data type that defines variables for the state of an object and method for an object’s behavior.3 Designing and Writing a Class Designing a class requires choosing the data the object will store and determining the actions and communication the object will provide. The design should include variable names and method names along with a description of the method and any required parameters.4 Designing and Writing a Class A class is written in a separate file and consists of a declaration and a body. The class declaration includes the access level, the keyword class, and the class name. The class body contains variables, constructors, and methods. A class takes the form: class { }5 Writing Constructors A constructor of a class is automatically executed when object is instantiated. Once an object is instantiated, the method members of the class can be called in any order. Unexpected results may occur if an accessor method is called before a member variable has been set to a valid value. To prevent this, variables should be initialized in the constructor. public (){ }6 Instance and Class Members Each object, or instance, of a class has its own copy of variables called instance variables. A class may also contain class variables. A class variables is declared with the keyword static and only one copy is maintained for all objects to refer to.7 The Object Class The Object class is the superclass of all other classes.8 Classes Using Classes A cless may contain member variables that are class data types. Complex data can be easily represented in this way. A class that contains class member variables demonstrates a has-a relationship.9 Object-Oriented Development Object-oriented programming requires that the solution to a task be implemented as a system of objects. In this system, objects communicate with other objects to provide a solution to the task. This approach to creat software is called object- oriented development.10
Tìm kiếm theo từ khóa liên quan:
Java programming language Bài giảng ngôn ngữ lập trình Java Designing and writing a class Writing constructors instance and class members The object classGợi ý tài liệu liên quan:
-
Bài giảng Chương 1: Cơ bản về ngôn ngữ lập trình Java
19 trang 26 0 0 -
Bài giảng Ngôn ngữ lập trình Java: Chương 6.2 - TS. Phan Nguyên Hải
34 trang 25 0 0 -
Bài giảng Ngôn ngữ lập trình Java: Phần 2 - TS. Vũ Hữu Tiến
65 trang 24 0 0 -
Bài giảng Ngôn ngữ lập trình Java căn bản
115 trang 21 0 0 -
Bài giảng Công nghệ Java: Chương 0 - Trần Quang Diệu
6 trang 21 0 0 -
Lecture Introduction to Java programming - Chapter 15: Graphics
32 trang 21 0 0 -
Lecture Introduction to Java programming - Chapter 1: Introduction to computers, programs, and Java
63 trang 18 0 0 -
Bài giảng Ngôn ngữ lập trình Java: Chương 4 - TS. Phan Nguyên Hải
56 trang 18 0 0 -
Lecture Java programming language: Inheritance and Polymorphism - Ho Dac Hung
11 trang 17 0 0 -
Bài giảng Ngôn ngữ lập trình Java: Chương 5 - TS. Phan Nguyên Hải
33 trang 16 0 0