How to restrict node access based on user roles? How can I allow only specific nodes to be displayed based on user roles?

Basically, I do not want to allow nodes to be accessed by users of some specific role.
What you're talking about is Drupal node access control, which is a huge subject.

The core's built-in support for node access control is rather coarse, and to control access to view a node by role, you must use some sort of node access control module.  

There is a page at Drupal.org listing all node access modules, with a capsule review of each.  I suggest you take a look at that page to see if you can find a suitable module to control access based upon roles.

When working with access control, it helps to understand how Drupal access control modules actually work, here is a quick description:


Users granted permission to administer nodes are never restricted by node access control. Users who do not have permission to View published content can never be granted access by a node access module. Only users who have 'access content' and not 'administer nodes' are eligible for the wild world of node access module control.
Node access control in Drupal is as a rule additive. This means that any module doing access control in accordance with the “the Drupal philosophy” should only allow access, not deny it. An administrator who wants to fine tune access to a node must first make sure nobody has access, and then add access grants to anyone that shall have access.


This means that it may be rather cumbersome to restrict access to individual with a module like Content Access, since you must start by denying everyone access, and then add it back to those nodes you don't want restricted.  However, I think it is the best option if you really need to do it node by node. Its primary resolution is content types, but it allows you to override this for single nodes.

Unfortunately, you shall not be able to use Deny access since it only works on content types, with no override for individual nodes.

NB: Using more than one node access module is not recommended.

Note that if you can change your requirements so that you can use content type as your basic unit for node access control, then Deny access would be ideal.   For instance, if you have a role "student" and you want to deny access to nodes with answers, then you can create a content type "Answer" (which can just be a clone of the default "Article") and Deny access will take care of protecting all nodes of the type "Answer" from being viewed by the role "student".