Official figures showed gross domestic product (GDP) rose by 0.4% between April and June, with better-than-forecast growth of 0.3% in June.