Can items themselves be mandatory, or only their related processes?
I distinctly recall being told that "uniforms are not mandatory, but the wearing of them is". The person was explaining that (in their opinion) many people get this wrong. They went on to say that exam questions aren't mandatory, but filling them in is.
I recently discussed this with my girlfriend – we're both interested in grammatical subtleties – but I couldn't find anything on the internet to support what I believe is the correct view on this.
"Mandatory" is an adjective that modifies a noun (things or processes), indicating an obligation.
In your examples:
"[U]niforms are not mandatory, but the wearing of them is."
"[E]xam questions aren't mandatory, but filling them in is."
The implied modification is that "wearing" in the first sentence and "filling" in the second sentence is "mandatory". The reference to the nouns "uniforms" and "exam questions" as not being "mandatory" does not mean that those nouns (things) cannot be mandatory, the negative aspect is used there to set up the following clause.
The adjective "mandatory" placement can modify its noun before the noun or after verbs of to be as a predicate adjective.
Mandatory:
It makes sense as a joke. Your friend is being hyper-literal: Wearing uniforms is mandatory. Answering questions is mandatory.
The act is mandatory, not the object. You can't order a uniform to do something. You can order someone to do something with a uniform.
But we know what to do when we're told that that uniforms are mandatory.