A)
Class A
{
int a ;
int b;
Void x()
{
System.out.ptonyln(“a :”+a);
System.out.ptonyln(“b :”+b);
}
}
Class object example
{
Public static void main(String [] a)
{
A r= nre A();
r.x();
}
}
Output :
a=0
b=0
->java reference not contain the address of the object but it contains the hash code which is depending upon the object address it is almost equal to the exact object address but not exact object address.
->java pointer is a restricted pointer.
->object is a structure variable, class is nothing but a structure.
->some memory area allocated is called object. “new” operator construct the object.
-> “new” is a operator is it allocating memory dynamically, new operator create the object.
1) string concatenation operator – at least one operand string then ‘+’ act as string concatenation operator.
2) arithmetic operator- both operands are values then ‘+’ acts as arithmetic/add operator.
->operator overloading is not object oriented feature.
->java not contain operator overloading. In java internally only one operator is overloaded i.e., “+”. It is acts as 2 things.
->in the above example , class A is instantiated. Instantiation means object creation.
->the fallowing syntax is used to create the object.
New A();
Comments
Post a Comment