Java
class and object programming example
Ø
What
is Class?
· A class is a user-defined blueprint or prototype from which objects are created. it represents the set of properties or methods that are common to all objects of one.
·
Example:- class Cat
Ø
What
is an object?
· An object is an instance of a class objects have states and behaviors
· Example:-- a dog has states –color, name breed as well as behavior ---wagging the tail, braking, eating
Ø
Definition
of a class:
§ Class is the collection of objects.
§ Class is not a real-world entity. it is just a template or blueprint or prototype.
§ Class does not occupy memory.
Syntex:-- public class Dog {
int legs;
int eyes;
}
Public: is an access modifier
0 Comments