What is Object in Java and what are it's Uses?
Definition
A class instance is known as Objects. In java object is the runtime entity of a class
Uses
Object is used to access the class members (both data member and member function)
Example
class hunteye {
//data member
int x ;
//member function
void set(){
x=13;
}
void get(){
System.out.println("x = "+x);
}
public static void main(String[] args) {
hunteye obj = new hunteye(); //object is created here
obj.set(); //object is access member function here
obj.get();
}
}
0 Comments:
Post a Comment