Chapter3_1-ClassesAndObjects

Classname att1 datatype1 atti datatypei m1 datatype1

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: rtments stacked vertically. • The top compartment shows the class's name. • The middle compartment lists the attributes. • The bottom compartment lists the operations: methods or services. ClassName - att1: dataType1 -… - atti: dataTypei + m1(…): dataType1 + ... + mj(…): dataTypej Page 12 Dr. S. GANNOUNI & Dr. A. TOUIR Attributes Methods (Services) Introduction to OOP Attribute • An attribute is an abstraction of a single characteristic possessed by all objects of the same class. • An attribute has a name unique within the class. • There are two types of attributes: • Class attributes – Independent of any object and their values are shared by all objects of the class. • Instance attributes – Dependent to the objects and their values are associated with and accessed through objects. Page 13 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Declaring a Class with Java ClassName - att1: dataType1 -… - atti: dataTypei + m1(…): dataType1 + ... + mj(…): dataTypej Attributes Methods (Services) public class ClassName { // Attributes // Methods (services) } Page 14 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Declaring Attributes With Java <modifiers> Modifiers Modifiers public Page 15 <data type> <attribute name> ; Data Type Data Type String Name Name studentName ; Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Example of a Class Declaration with Java public class Course { // Attributes public String studentName; public String courseCode ; // No method Members } Page 16 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP...
View Full Document

This document was uploaded on 03/03/2014.

Ask a homework question - tutors are online