Consider the following code snippet: anEmployee = Programme…
Consider the following code snippet: anEmployee = Programmer() anEmployee.increaseSalary(2500) If the Programmer class inherits from the Employee class, and both classes have an implementation of the increaseSalary method with the same set of parameters, which statement is correct?
Read DetailsConsider the following code segment: class Employee : def _…
Consider the following code segment: class Employee : def __init__(self, name: str) -> None: . . . def getSalary(self) : . . . . . . class Programmer(Employee) : def __init__(self, name: str) -> None: . . . def writeProgram(self) : . . . Which of the following code segments is not legal?
Read DetailsConsider the following task hierarchy — representing some u…
Consider the following task hierarchy — representing some unit of work to be completed. class Task: def __init__(self, label: str) -> None: self._label = label def cost(self) -> int: raise NotImplementedError(“bad”) class FixedTask(Task): def __init__(self, label: str, minutes: int) -> None: super().__init__(label) self._minutes = minutes def cost(self) -> int: return self._minutes * 2 def __repr__(self) -> str: return f”FixedTask(label={self._label}, cost={self.cost()})” def main() -> None: items: list[Task] = [ FixedTask(“x”, 10), FixedTask(“y”, 3) ] for t in items: print(t) main() What prints?
Read DetailsConsider the following code snippet: aVehicle = Auto() aVeh…
Consider the following code snippet: aVehicle = Auto() aVehicle.moveForward(200) If the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters, which statement is correct?
Read Details