Overlapping courses will not be included in your degree. It must be clearly stated in the syllabus when two courses have essentially the same content, ie overlapping courses. If there is any uncertainty regarding the contents of similar courses, you should contact the relevant examiner.
Optional courses will not be counted as part of your degree. When you apply for your graduation certificate, any optional courses will be listed in your transcripts over and above your degree.