Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!