Chapter3_2-ObjectsAndInstanceAtributes

Course1 object course course course1 course2 course1

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: Student class is defined, we can create several instances. course1 Object: Course Course course1, course2; course1 = new Course( ); course2 = new Course( ); Instance variable studentName course2 courseCode Object: Course Object reference studentName courseCode Object state Page 8 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Instance VS. Primitive Variables • Primitive variables hold values of primitive data types. • Instance variables hold references of objects: the location (memory address) of objects in memory. • Note: Memory addresses are usually written in hexadecimal notation, beginning with a 0x (for example, 0x334009). These addresses are unique for each object and are assigned while a program runs. Page 9 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Heap and Stack Memory • Objects and their attributes and methods are usually stored in heap memory. • Heap memory is dynamically allocated memory chunks containing objects while they are needed by the program. • Other variables are usually stored in stack memory. • Stack memory is used for storing items which are only used for a brief period of time (shorter than the life...
View Full Document

Ask a homework question - tutors are online