• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

passing of messages

 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
How do objects pass messages in Java?
1) using instance variables
2) using instance methods
3) using static variables
4) using static methods
Regards
Neha
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi neha,
I'm not sure whether this will help you or not but my idea as far as messages are concerned is,
-objects are instantiable entity and so we can apply message passing for those only and not to the variables (which are simply memory locations) or classes.
when we say a.i = 10 where a is some object ref then the memory allocated to i in object a is set to value 10 but that is direct. instead if we say a.setI(10) which sets variable i in a as 10 then we can say we passed a message to object a to do something.
static(class) methods and static variables are again manipulated directly using classname.variable or classname.method(). if we call a static method, that will cause only static values to be changed and so again we are manipulating memory locations directly.
so my answer would be,
messages can be passed through only instance methods.
Cheers!
Maulin
 
Neha Sawant
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I too feel it should be instance methods.
Does anyone else have any other answer for it
Regards
Neha
 
Well THAT's new! Comfort me, reliable tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic