How to get current page id through the plugin

Take a look at the Plugin API/Action Reference, particularly the section Actions Run During a Typical Request.

In WordPress, you’re going to want to hook your code to various specific points of execution, otherwise it will be executed immediately, which is often not the desired result.

The code you posted is going to be executed as soon as the plugin is loaded, which takes place on the plugins_loaded hook. That’s way too early in the flow of loading a page (for example) to be getting a post/page ID.

Below, I’ve wrapped your code in a function that is hooked to the template_redirect hook and now it generates the expected results.

add_action( 'template_redirect', 'wpse_inspect_page_id' );
function wpse_inspect_page_id() {
    $page_object = get_queried_object();
    var_dump($page_object);

    $page_id = get_queried_object_id();
    echo $page_id;
}