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
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