How to redirect to a page after form submit in Drupal 8

You can redirect the user to any page after form submission in the following way.

//Don't forget to include this in beginning. This will only work in submitForm function.
use Drupal\Core\Url;
//Constructing a URL.Will redirect to example-page with query paramter q = 5.
$response = Url::fromUserInput('/example-page?q=5');