3 answers
So __r is used to access fields on the Related Parent Object(related either via Lookup Relationship or a Master-Detail Relationship) is SOQL Queries, in Visualforce Bound Variables etc. SOQL Queries:
SELECT Id, Account.Name, Account.BillingStreet FROM Contact
Formula Fields:
Account.Name, Account.BillingStreet
Visualforce Tags:
<apex:ouputField value="{!Contact.Account.Name}" />
SOQL Queries:
SELECT Id, Contact__r.Name, Contact__r.Mobile FROM Opportunity
Formula Fields:
Contact__r.Name, Contact__r.Mobile
Visualforce Tags:
<apex:ouputField value="{!Opportunity.Contact__r.Name}" />
we use __r in realationship queries(for custom objects) . it is used in relationship query