GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

Consider 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

Consider the following animal hierarchy. class Animal:    de…

Consider the following animal hierarchy. class Animal:    def __init__(self, name: str, age: int) -> None:        self._name = name        self._age = age     def speak(self) -> str:        raise NotImplementedError(“bad”) class Dog(Animal):    def speak(self) -> str:        return “woof”     def __repr__(self) -> str:        return f”Dog(name={self._name}, age={self._age}, sound={self.speak()})” class Cat(Animal):    def speak(self) -> str:        return “meow”     def __repr__(self) -> str:        return f”Cat(name={self._name}, age={self._age}, sound={self.speak()})” def main() -> None:    animals: list[Animal] = [ Dog(“Rex”, 5), Cat(“Milo”, 2) ]    print(animals) main() What gets printed when the main is run?

Read Details

Insert the missing code in the following code fragment. This…

Insert the missing code in the following code fragment. This fragment is intended to call the Vessel class’s method. class Vessel : def setVesselClass(self, vesselLength: int) -> None : … class JetSki(Vessel) : def __init__(self) : __________________ mySki = JetSki()

Read Details

Consider the following program: class Dinosaur : def __init…

Consider the following program: class Dinosaur : def __init__(self, name: str = “dinosaur”) -> None: self._name = name def display(self) -> None: print(self._name) class Triceratops(Dinosaur) : def __init__(self) -> None: super().__init__(“triceratops”) x = Dinosaur() x.display() What is displayed when it executes?

Read Details

Consider the following program: class Dinosaur : def __init…

Consider the following program: class Dinosaur : def __init__(self, name: str = “dinosaur”) -> None: self._name = name def display(self) -> None: print(self._name) class Triceratops(Dinosaur) : def __init__(self) -> None: super().__init__(“triceratops”) x = Triceratops() x.display() What is displayed when it executes?

Read Details

Which set of classes is poorly designed?

Which set of classes is poorly designed?

Read Details

Consider the following class definitions: class Dinosaur :…

Consider the following class definitions: class Dinosaur : . . . def eat(self, what: str) -> None : . . . class Triceratops(Dinosaur) : . . . ____________________ . . . What statement should be placed in the blank to override the implementation of the eat method?

Read Details

Consider the following small animal hierarchy… class Anima…

Consider the following small animal hierarchy… class Animal:    def speak(self) -> str:        return “???” class Dog(Animal):    def speak(self) -> str:        return “woof” class Cat(Animal):    def speak(self) -> str:        return “meow” def main() -> None:    animals: list[Animal] = [Dog(), Cat(), Animal()]    for a in animals:        print(a.speak()) main() What will the main print when run?

Read Details

Consider the following class hierarchy: class Animal:    def…

Consider the following class hierarchy: class Animal:    def speak(self) -> str:        return “???”     def shout(self) -> str:        return self.speak().upper() class Dog(Animal):    def speak(self) -> str:        return “woof” def main() -> None:    animals: list[Animal] = [ Dog() ]    print( animals[0].shout() ) main()

Read Details

You are creating a Motorcycle class which is supposed to inh…

You are creating a Motorcycle class which is supposed to inherit from the Vehicle class. Which of the following class declaration statements will accomplish this?

Read Details

Posts pagination

Newer posts 1 … 4,124 4,125 4,126 4,127 4,128 … 83,154 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top