I've bought domain, which was previously used by somebody back in 2007. Now I've realized  that internet is full of backlinks that point to non-existing parts (pages) under my website-domain (for example to mypage.com/whatever, where whatever is not present on my website, so 404 error shows).I want to ask, are these links counted by google (for pagerank) and other search engines, or not. So do I have to redirect these links to existing pages in order to be counted?
Backlinks for nonexisting page
pagerank;backlinks
Yes, those backlinks can be taken into account by Google (but not if they lead to 404 pages).Now, you have two opportunities, let's choose one (I advise you the first one):you can mark these URLs as Gone (410 HTTP status) to specify to search engines these pages never longer exist. In this case, these 404 errors will disappear, you take no risk for your site but you don't profit by these backlinks for SEO.you can try to 301 redirect all these backlinks URL to your existing pages but you need to be sure the old domain treated the same theme of your website and your 301 redirect must be applied to a new page, relevant in relation to the old one (you need to get back the content of the old domain for this). In this case, these 404 errors will disappear too, you take risks for your site if you don't take all needed precautions but you can profit by these backlinks for SEO.