Selenium Interview : How do you simulate browser back and forward in Selenium?

How do you simulate browser back and forward in Selenium?

Answer: The sample code is as follows:

WebDriver driver=new ChromeDriver();

driver.navigate().back();

driver.navigate().forward();