0
What is the difference between an attribute and an object?
3 ответов
+ 1
An object is an instance of a class (class is like a blue print, like a description of the parts of something)
Objects are made of attributes(variables inside the class) and methods
+ 1
object is an instance of a class.
which you create by writing classname obj=new classname();
we create the object to use the member variables and functions of a class. new keyword is used to allocating the memory for an object of a class.
we can say to refer a class by another class, we create the object of that class.
attributes defines the properties of the class.
they are member variables of a class . they can be instance variables or class variables(static variables).
for example
if u have a class called "student"
the common attributes of student class (we can say member variables)
can be: ID, name, rollno, etc.
to access these variables from another class or from main method , we have to create the instance or object of that class.
0
thank-you guys!😀