






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!























Prepared By Dr Jamal Zraqou
An encapsulated object can be thought of as a black box – its inner workings are hidden from the client The client invokes the interface methods of the object, which manages the instance data 1- 4 Methods Data Client
Abstract Data Types (ADTs)
Abstract Data Types (ADTs)
visibility modifiers
1- 8
Parameters When a method is called, the actual parameters in the invocation are copied into the formal parameters in the method header char calc (int num1, int num2, string message) { int sum = num1 + num2; char result = message.charAt (sum); return result; } ch = obj.calc (25, count, "Hello");
1- 13
1. protected void finalize throws Throwable()
Static Class Members
1- 14
(^) The order of the modifiers can be interchanged, but by convention visibility modifiers come first (^) Recall that the Main method is static – it is invoked by the Java compiler without creating an object (^) Static methods cannot reference instance variables because instance variables don't exist until an object exists (^) However, a static method can reference static variables or local variables 1- 16
Class Relationships (^) Classes in a software system can have various types of relationships with each other (^) Three of the most common relationships: (^) Dependency: A uses B (^) Aggregation: A has-a B (^) Inheritance: A is-a B (^) Let's discuss dependency and aggregation further (^) Inheritance is discussed in detail in Chapter 8
Dependency (^) Some dependencies occur between objects of the same class (^) A method of the class may accept an object of the same class as a parameter (^) For example, the Replace method of the string class takes as two parameters for other string objects: string st1="University",st2=“i”; st1 = st1.Replace(st2, "a"); System.Console.WriteLine(st2); Output: Unaversaty This drives home the idea that the service is being requested from a particular object
An aggregate is an object that is made up of
Therefore aggregation is a has-a relationship