Step 3: Creating .routing.yml
Before registering the hook_menu we have to write the path in .routing.yml file.
In Drupal 8 we won’t need hook_menu() anymore as we make heavy use of the Symfony2 components to handle the routing. This involves defining the routes as configuration and handling the callback in a controller (the method of a Controller class).
Here the example.routing.yml

Step 4: Creating Route Controller Class
We have to create our ModuleController.php according to the PSR-4 naming standard [https://www.drupal.org/node/2156625].
Here we have file structure, "modules/custom/example/src/Controller/ExampleController.php".
ExampleController.php

Step 5: Creating .module with hook_menu()
In Drupal 8 hook_menu() function we have two conditions to follow.
(1)The paths need to match with path given in ".routing.yml" exactly.
(2)Should match the name of the route.
Here is the example.module

Finally you can go to "mypage/page", and see the "Hello world is getting printed".
Click on Download-module to download the example module in drupal 8