Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 3
What does the System.out.println(<objectname>) print?...
What result this code gives?... https://code.sololearn.com/c2qRx3x2AlKZ/?ref=app
4 Answers
+ 6
you accidentally made copies of you question ,please remove this because it has no value:
https://www.sololearn.com/Discuss/1768295/?ref=app
edit : kool👍😊 Paranoid
+ 2
"Program@xxxxxx" means that it's located in memory on place xxxxxx.
+ 2
Done...
+ 2
The syntax of the output is as follows :-
ProjectName.ClassName@******
Here, ****** represents six characters(may be digits or alphabets) hashcodes. Hashcodes values will vary every time you run the program.
Explaination ------
Example:-
class Program {
static void main (String[] args) {
Program ob = new Program ();
System.out.println(ob);
}
}
In the above example, when you run the code the ob will by default call toString() function of class Objects (by default every class extends Object class).
And toString() will print the output.
I hope you'll better understand now .
This questions has been asked in many Java interviews.