Chapter3_2-ObjectsAndInstanceAtributes

Studentname has the course course2coursecode page

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: t; has the course “+ course1.courseCode); System.out.println(course2.studentName + " has the course “+ course2.courseCode); } } Page 17 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Practical hint • Class Course will not execute by itself – It does not have method main • CourseRegistration uses the class Course. – CourseRegistration, which has method main, creates instances of the class Course and uses them. Page 18 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Class and Instance Attributes • Instance attributes (and methods) are: • associated with an instance (object) of the class. • and accessed through an object of the class. • each object of the class has its own distinct copy of instance attributes (and methods) • Class attributes (and methods): • live in the class • can also be manipulated without creating an instance of the class. • are shared by all objects of the class. • do not belong to objects’ states. Page 19 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Class Attributes and Objects • A class attribute is in one fixed location in memory. • Every object of...
View Full Document

This document was uploaded on 03/03/2014.

Ask a homework question - tutors are online