• Post Reply Bookmark Topic Watch Topic
  • New Topic

program statements  RSS feed

 
Raj Gurung
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
in the following program:



what will be the value of e1.count and e2.count???

thank you
 
Charles D. Ward
Ranch Hand
Posts: 99
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you ran it and what were you expecting?
 
Raj Gurung
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,
i am sure, e1.count and e2.count both equals to 0, as int count = 0 in declared in Echo class.
is it correct???
there is no output for this program as i just took out part to understand my doubt.

thanks
 
Paul Clapham
Sheriff
Posts: 22838
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you would understand it a lot better if you spent a few seconds adding the code to output that data.
 
Raj Gurung
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i had used for a output, and i found e1.count and e2.count both equals to 0, as int count = 0 is declared in class Echo.
am i correct???

thanks
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if it is what you found and the output proves that, then it is correct. Can be differently?
 
Raj Gurung
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, thank you
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj, so, explain us in simple words once again, what is the difference between those 2 scenarios?
So we could make sure you understood.

 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj Gurung wrote:Hi,
i had used for a output, and i found e1.count and e2.count both equals to 0, as int count = 0 is declared in class Echo.
am i correct???

It doesn't appear that you actually ran that code and displayed the values after the assignment statements were executed because you are NOT correct. In fact, I am sure you haven't run that code because it won't even compile as shown.

A word of advice, Raj: you will eventually run out of goodwill from others on this site if you don't DoYourOwnHomework and ShowSomeEffort (←click on those links). "Doing your homework" does not just pertain to actual school work but also means that you need to do your part in trying to learn, which includes compiling and running the code and trying to figure out for yourself what's happening.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!