Class and object in oops in python by R4R Team

Object oriented programming terminology-


Class-
A user defined prototype for an object that define a set of attributes that characterize any object of the class.

class variable-
A variable that is shared by all instances of a class.

Data member-
A class variable or instance variable that holds data associated with a class and its object.

Instance-
An individual object of the class

Instantiation-
The creation of instance of the class.

Create class and object
program-

#create class with class attributes
class Computer():
i=10
s="This is class"

#create first object
obj1=Computer()
print(obj1.i)
print(obj1.s)

#create second object
obj2=Computer()
print(obj2.i)
print(obj2.s)


output-

10
This is class
10
This is class


-In this program, we create a class by using 'class' keyword named as Computer() that contain 2 attributes one is integer type and another one is of string.
-then we create a two object of this class and called that attributes and print that value.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!