following is the equivalent program written in java this program wil alos produce the same result