A) Create an abstract class 'Fares' with an abstract method 'fareCharged()'. $10, $15 and $20 are the fares charged by Bus, Auto and Cab respectively. 'Bus', 'Auto' and 'Cab' are subclasses of class 'Fares', each having a method named 'fareCharged()' which prints the fare charged by different vehicles. Call this method by creating an object of each of the three classes. Expected Output: Fare charged by Bus is $10 Fare charged by Auto is $15 Fare charged by Cab is $20

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 6SA
icon
Related questions
Question
100%

By java programming only.

 

A) Create an abstract class 'Fares' with an abstract method 'fareCharged()'. $10, $15 and $20 are the
fares charged by Bus, Auto and Cab respectively. 'Bus', 'Auto' and 'Cab' are subclasses of class
'Fares', each having a method named 'fareCharged()' which prints the fare charged by different
vehicles. Call this method by creating an object of each of the three classes.
Expected Output:
Fare charged by Bus is $10
Fare charged by Auto is $15
Fare charged by Cab is $20
Transcribed Image Text:A) Create an abstract class 'Fares' with an abstract method 'fareCharged()'. $10, $15 and $20 are the fares charged by Bus, Auto and Cab respectively. 'Bus', 'Auto' and 'Cab' are subclasses of class 'Fares', each having a method named 'fareCharged()' which prints the fare charged by different vehicles. Call this method by creating an object of each of the three classes. Expected Output: Fare charged by Bus is $10 Fare charged by Auto is $15 Fare charged by Cab is $20
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Multithreading Methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning