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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started