Lec 1
Lec 1
Defining Abstraction
Abstraction is the process of extracting common features from
specific examples
Abstraction is a process of defining the essential concepts while
ignoring the inessential details
Class is an abstraction of all possible objects
2
Everything is an Object
3
Defining an Object
4
Class as Abstraction
A class is an abstraction of its instances.
It defines all the attributes and methods
that its instances must also have.
Person
name
gender
age
tellGender()
tellAge()
5
Defining a Class
A Class acts as the template from which an object is created. The
class defines the properties of the object and the methods used to
control the object's behavior.
A Class specifies the structure of data as well as the methods which
manipulate that data. Such data and methods are contained in each
instance of the class.
A Class is a model or template that can be instantiated to create
objects with a common definition, and therefore common
properties, operations and behavior.
A Class provides a template for defining the behavior of a particular
type of object. Objects are referred to as “instances” of a class.
6
Basic Terminology
A class defines a kind of objects:
specifies the kinds of attributes (data) an object of
the class can have.
provides methods specifying the actions an object
of the class can take.
An object is an instance of the class.
Person is a class
Alice and Bob are objects of the Person class.
A Class as an Outline
public class Point
{
public int x , y; //data , attributes , properties
//behavior
public void move(int dx, int dy) {
x += dx; y += dy;
}
}