Final answer:
Trying to access a field not specified in a SELECT clause of a SOQL query will lead to the System.SObjectException, since in Salesforce, only the fields specified in the SELECT clause can be accessed.
Step-by-step explanation:
When you attempt to access a field for a record that was returned by a SOQL query but was not specified in the SELECT clause, you'll get a SObjectException.
The SELECT clause specifies which fields to retrieve in a query, so if a field is not included in the SELECT clause, it will not be available for access. To access a specific field, you must include it in the SELECT clause of your SOQL query.
This is because in Salesforce Object Query Language (SOQL), you can only access the fields specified in the SELECT clause of the query. Otherwise, trying to access a not included field would lead Salesforce to throw a runtime exception - System.SObjectException. This is an important aspect to understand when coding apex in the Salesforce environment.
Learn more about SOQL query