Answer:
D)One big superclass can be used instead of many little classes.
Explanation:
Inheritance could be described as getting new class on another existing class with almost same execution,
inheritance allows codes to be re-used. It should be noted that inheritance bring about the code sharing among class.
The advantages of using inheritance includes but not limited to
✓ Code that is shared between classes needs to be written only once.
✓Similar classes can be made to behave consistently.
✓ Enhancements to a base class will automatically be applied to derived classes.
Answer:
Following are the statement is given below
if(updateDirection ==1) // check condition
{
++numUsers; // increments the value
}
else
{
--numUsers; // decrement the value
}
Explanation:
Following are the description of statement
- Check the condition in the if block .If the "updateDirection" variable is 1 then then control moves to the if block otherwise control moves to the else block statement.
- In the if block the statement is "++numUsers" it means it increment the value by 1 .
- In the else block the statement is "--numUsers" it means it decrement the value by 1 .
A select query
select column1, column2, columnN
from table
where condition
order to be pretty;
Answer:
class Car(object):
fuel = 0
def __init__(self, mpg):
self.mpg = mpg
def drive(self, mile):
if self.fuel * self.mpg >= mile:
self.fuel -= mile / self.mpg
else:
print(f"get gas for your {self}")
print(f"Fuel remaining: {self.fuel}")
#classmethod
def get_gas(cls):
cls.fuel += 50
#classmethod
def add_gas(cls, gallon):
if cls.fuel + gallon > 50:
cls.fuel += 10
else:
cls.fuel += gallon
gulf = Car(20)
gulf.get_gas()
gulf.drive(200)
Explanation:
The Car class is defined in Python. Its drive method simulates the driving of a car with fuel that reduces by the miles covered, with efficiency in miles per gallon. The get_gas and add_gas methods fill and top up the car tank respectively.