Object vs. Class! - Politehnica University of...
Transcript of Object vs. Class! - Politehnica University of...
![Page 1: Object vs. Class! - Politehnica University of Timișoaracs.upt.ro/~cristina/teaching/oop-en/ObjectsAndClasses.pdfsome class, and whose classes are all members of a hierarchy of classes](https://reader034.fdocuments.in/reader034/viewer/2022050122/5f5264f6d6833c424e5d39ba/html5/thumbnails/1.jpg)
Objects and Classes
Suggested Reading: Bruce Eckel, Thinking in Java (Fourth Edition)Introduction to Objects, Everything is an Object
Dr. Cristina Marinescu
An example in C...
2
Dr. Cristina Marinescu
Same example in Java...
3 Dr. Cristina Marinescu
Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class, and whose classes are all members of a hierarchy of classes united via inheritance relations.[G. Booch et al. Object-Oriented Analysis and Design with Applications. 3rd edition, 2007.]
4
![Page 2: Object vs. Class! - Politehnica University of Timișoaracs.upt.ro/~cristina/teaching/oop-en/ObjectsAndClasses.pdfsome class, and whose classes are all members of a hierarchy of classes](https://reader034.fdocuments.in/reader034/viewer/2022050122/5f5264f6d6833c424e5d39ba/html5/thumbnails/2.jpg)
Dr. Cristina Marinescu 5
Object vs. Class!
Dr. Cristina Marinescu
An Object has...
6
Identity(memory address)
Interface(known by its user)
Behavior(known by its implementer)
State(given by its attributes)
Dr. Cristina Marinescu 7 Dr. Cristina Marinescu 8
![Page 3: Object vs. Class! - Politehnica University of Timișoaracs.upt.ro/~cristina/teaching/oop-en/ObjectsAndClasses.pdfsome class, and whose classes are all members of a hierarchy of classes](https://reader034.fdocuments.in/reader034/viewer/2022050122/5f5264f6d6833c424e5d39ba/html5/thumbnails/3.jpg)
Dr. Cristina Marinescu 9 Dr. Cristina Marinescu
Access Specifiers
10
X
Dr. Cristina Marinescu
A Constructor
11
has the same name as the class it belongs to
does not return a value(neither void)
is called only when a class is instantiated
Dr. Cristina Marinescu 12
A constructor was added...
![Page 4: Object vs. Class! - Politehnica University of Timișoaracs.upt.ro/~cristina/teaching/oop-en/ObjectsAndClasses.pdfsome class, and whose classes are all members of a hierarchy of classes](https://reader034.fdocuments.in/reader034/viewer/2022050122/5f5264f6d6833c424e5d39ba/html5/thumbnails/4.jpg)
Dr. Cristina Marinescu 13
Static Members
Dr. Cristina Marinescu 14
Static Members
Dr. Cristina Marinescu 15
Final Members
Dr. Cristina Marinescu 16
Unified Modeling Language (UML) - an example