A reference is an alias or a pointer to an object in memory. It allows multiple variables to refer to…