Yes, since zero has a square root. (Although the result of the calculation turns out not to be exactly zero.)
It is good to get into the habit of worrying about what happens with special values. The program does happen to work with zero. Here is the output of the program for several values:
C:\chap23>java SquareRoot Enter the number: 0 The square root of 0.0 is 1.1113793747425387E-162 C:\chap23>java SquareRoot Enter the number: 0.0000000000000000000003 The square root of 3.0E-22 is 1.732050807568877E-11 C:\chap23>java SquareRoot Enter the number: -12 Please enter a positive number C:\chap23>java SquareRoot Enter the number: 144.0 The square root of 144.0 is 12.0
Suggest a few other values with which the program should be tested.