Class and Object
Class and Object
// ...
type instance-variableN;
Access type methodname1(parameter-list) {
// body of method
}
type methodname2(parameter-list) {
// body of method
}
// ...
type methodnameN(parameter-list) {
// body of method
}
}
Access specifier
• Public
• Private
• Protected
• default
• The data, or variables, defined within a class are called
instance variables.
• The code is contained within methods.
• The methods and variables defined within a class are
called members of the class.
• Instance variables are acted upon and accessed by the
methods defined for that class.
• Methods determine how a class’s data can be
used.
• Variables defined within a class are called
instance variables because each instance of the
class contains its own copy of these variables.
• data for one object is separate and unique from
the data for another.
Declaring objects
• when we create a class, a new data type.
• We can use this type to declare objects of that type.
---
}
byte b=sum();