15. Polymorphism
A feature that allows 1 interface to be used for a general class of actions.
Steering Wheel
Power Steering Wheel Steering wheel of an Electric car
19. Class and Objects
A class consists of members: data and methods.
Class Name
@interface Employee: NSObject
{
int empId;
char *name; Members: Data
}
-(int) empId;
Members: Methods
-(int)lengthOfService:date;
@end
20. Objects
id date=[ [ Date alloc ] init ]; New Date object allocated
[ date release];
Releasing the variable
25. Dynamic binding + Message Passing
main
{
Window *W = [[Window alloc] init];
View *V = [[view alloc] init];
[W flush];
[V flush];
id anotherObj = W; Dynamic Binding
[anotherObj flush]; Message Passing
}
The flush message is passed to the variable anotherObj that is dynamically bound during runtime.
26. Summary
The OOPs features that Objective C exhibits are as follows:
• Abstraction
• Encapsulation
• Class
• Object
• Inheritance
• Polymorphism
• Message passing
• Dynamic Binding