Wipro interview question

Java coding with two scenario