Objects communicate with one another by sending or receiving information to or from each other. A message for an object is a request for execution of a procedure and therefore will invoke a function in the receiving object that generates the desired results. Message passing involves specifying the name of the object, the name of the function and the information to be sent. |
main
method has the following message passing:
public class TestVehicle { public static void main( String[ ] args ) { ... Sale veh1 = new Sale( "FG1000", args[0], "B-Class", 100000.00, 25000 ); ((Sale) veh1).setDepreciation( 20.0 ); ... } } |
java.io
package is a highly cohesive package because it has I/O related classes and interfaces.
However, the java.util
package is a weakly cohesive package because it has unrelated classes and interfaces.
“The only way to get through life is to laugh your way through it. You either have to laugh or cry. I prefer to laugh. Crying gives me a headache.” ― Marjorie Pay Hinckley |