0
What does this output mean?
What does this value of p mean and what object/class this p is refering to? And does newly created object in the main method also contains variable string ? https://code.sololearn.com/cG52NX1X0343/?ref=app
2 Answers
+ 1
According to your code, p is a reference variable pointing to an object of type Palak. You cannot directly print a reference variable like that. It will give you 'className@hashcode' of the object.
In order to get a readable result, you have to override the toString() method inside class Palak.
0
> And does newly created object in the main method also contains variable string ?
Palak p = new Palak(10);
p.pal = "value of pal";
System.out.println(p.pal);