Tag: Q&A

OOP – Inheritance – Q&A

Question 1[2 marks] Class File:​ private filename​ //Constructor for the File class procedure new(strFilename):​ filename = strFilename​ public procedure rename(strFilename)​ if strfilename!="":​ filename = strFilename​ Class MP3 inherits File:​ private title​ private artist​ private duration​ //Constructor for the MP3 class

OOP – Encapsulation – Q&A

Question 1[2 marks] class Padlock: private key private locked //Constructor for the Padlock class: procedure new(str_key,bool_locked): key = str_key locked = bool_locked public function unlock(combination): if combination==key: locked = False return True else: return False public procedure lock(): locked =