Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called MobileDevice with a private field deviceType that will be initialized to the string Mobile Device in the constructor. Include the corresponding

Create a class called MobileDevice with a private field deviceType that will be initialized to the string Mobile Device in the constructor. Include the corresponding setter and getter methods.

Create another class SmartPhone that will inherit MobileDevice, with a private field deviceType initialized to the string Smart Phone in the constructor, and override the getter method by returning the string:

Mobile Device -> Smart Phone. (Hint: To obtain this result make a call to the super class getter method).

Create three more classes: Android, iPhone, and WindowsPhone that will inherit SmartPhone, have a private field deviceType initialized to the string Android, iPhone, or Windows Phones correspondingly in the constructor, and override the getter method returning the corresponding string

Mobile Device -> Smart Phone -> iPhone for iPhone,

Mobile Device -> Smart Phone -> Android for Android, or

Mobile Device -> Smart Phone -> Windows Phone for Windows Phone.

Your classes must follow this hierarchy:

====> android

MobileDevicee ==> smartphone =====>iphone

=====>windows

Once you create the classes, run the following client code and report your output.

public static void main(String[] args) {public class MobileDeviceClient {

// TODO Auto-generated method stub

MobileDevice myMobileDevice = new MobileDevice();

SmartPhone mySmartPhone = new SmartPhone();

iPhone myiPhone = new iPhone();

Android myAndroid = new Android();

WindowsPhone myWindowsPhone = new WindowsPhone();

System.out.println(myMobileDevice.getDeviceType());

System.out.println(mySmartPhone.getDeviceType());

System.out.println(myiPhone.getDeviceType());

System.out.println(myAndroid.getDeviceType());

System.out.println(myWindowsPhone.getDeviceType());

}

}

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

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

What is the smallest common multiple of 160 and 240?

Answered: 1 week ago

Question

how would you have done things differently?

Answered: 1 week ago