0

Fill in the blanks to create an object of type Car and call its horn() method

Car c = ________Car(); __________();

19th Nov 2016, 9:36 AM
anjanel macalaguim
9 Antworten
+ 3
class Vehicle: def horn(self): print("Beep!") class Car(Vehicle): def __init__(self, name, color): self.name = name self.color = color obj = Car("BMW", "red") obj.horn()
1st May 2022, 9:35 PM
Erhan TEZER
+ 2
to create an object of type Car and call its horn() method Car c = new Car(); c.horn ();
3rd Mar 2017, 6:55 PM
Vira Yanchuk
Vira Yanchuk - avatar
+ 2
to create an object of type Car and call its horn() method Car c = new Car(); c.horn ();
5th Oct 2021, 1:41 PM
Gemechu Getachew
Gemechu Getachew - avatar
+ 1
;/
24th Jun 2023, 3:38 AM
NIKIL KUMAR M
NIKIL KUMAR M - avatar
+ 1
why
9th Sep 2023, 3:31 AM
PRADEEN D
PRADEEN D - avatar
0
waaaa thank you so much ~
19th Nov 2016, 12:51 PM
anjanel macalaguim
0
class Vehicle: def horn(self): print("Beep!") class Car(Vehicle): def __init__(self, name, color): self.name = name self.color = color obj = Car("BMW", "red") obj.horn() The code you have written defines a class Vehicle with a single method horn that prints "Beep!". Then you have defined another class Car that inherits from Vehicle and has an additional __init__ method to initialize the name and color attributes of the car. Finally, you create an object obj of class Car with the arguments "BMW" and "red", and call its horn method, which will result in the following output:
13th Feb 2023, 10:29 AM
Manhar Hadiyal
Manhar Hadiyal - avatar
0
class Person { int age; string name; public void SayHi() { Console.WriteLine("Hi"); } }
12th Aug 2023, 4:12 AM
NAVEENKUMAR R
NAVEENKUMAR R - avatar