According to Apache's guide to HTTP authentication. Both basic and digest authentication requires a UsernamePasswordCredentials instance.
My question is can I use the same client implementation for server authentication for both basic and digest following this example?
Yes, you can and you should. HttpClient is capable of employing different auth schemes in the course of a single request execution (for instance using Basic to authenticate with the proxy and NTLM to authenticate with the origin server)