There is a field named "Email Opt Out" in the contact object. Can we query this field and put in the filter condition if the "Email Opt Out" field does not have both "Field-Level Security" and "Field Accessibility" in the apex class.
Apex doesn't enforce FLS:
You can perfectly query a field in a SOQL query that isn't visible to the user, you can filter on it, but you won't see it in visualforce or in the layout.
Unless you make the field visible ofcourse.