Package Demo; Public classDemo { Public Static voidMain (string[] args) {Demo demo=NewDemo (); intDate =9; BirthDate D1=NewBirthDate (7,7,1970); BirthDate D2=NewBirthDate (5,8, -); Demo.change1 (date); Demo.change2 (D1); Demo.change3 (D2); } Public voidChange1 (inti) {i=1234; } Public voidChange2 (BirthDate b) {b=NewBirthDate ( A,2,2004); } Public voidChange3 (BirthDate b) {B.setday ( A); }}Test Class
Package Demo; Public classBirthDate {Private intDay ; Private intmonth; Private intYear ; PublicBirthDate (intDintMinty) { day=D; Month=m; year=y; } Public voidDisplay () {System. out. println (day+"-"+month+"-"+Year ); } Public intGetDay () {returnDay ; } Public voidSetday (intDay ) { This. Day =Day ; } Public intGetMonth () {returnmonth; } Public voidSetmonth (intmonth) { This. Month =month; } Public intgetYear () {returnYear ; } Public voidSetyear (intYear ) { This. Year =Year ; } }java Bean
Memory Analysis Diagram:
Java Memory analysis