Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (CarbonFootprint Interface: Polymorphism) Using interfaces, you can specify similar behaviors for possibly disparate classes. Governments and companies worldwide are becoming increasingly concerned with carbon

1. (CarbonFootprint Interface: Polymorphism) Using interfaces, you can specify similar behaviors for possibly disparate classes. Governments and companies worldwide are becoming increasingly concerned with carbon footprints (annual releases of carbon dioxide into the atmosphere) from buildings burning various types of fuels for heat, vehicles burning fuels for power, and the like. Many scientists blame these greenhouse gases for the phenomenon called global warming. Create three small classes unrelated by inheritance classes Building, Car and Bicycle. Write an interface CarbonFootprint with a getCarbonFootprint method. Have each of your classes implement that interface, so that its getCarbonFootprint method prints out an appropriate message (e.g., this message from Building CarbonFoot).Write an application that creates objects of each of the three classes and one interface reference variable, assign each object to the interface reference variable, and then invoke each objects getCarbonFootprint method by means of dynamic method resolution. For each object, print a simple message (e.g., this message from Building CarbonFoot).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

Graph the function f(x) = -3(x + 1) 2 + 5 using transformations.

Answered: 1 week ago

Question

1. What are the pros and cons of diversity for an organisation?

Answered: 1 week ago

Question

1. Explain the concept of diversity and equality in the workplace.

Answered: 1 week ago