The mood among German analysts and investors improved unexpectedly in June, reflecting their confidence in the resilience of Europe's largest economy.