dev-resources.site
for different kinds of informations.
Assignment smart phone
1) Create an abstract class named âSmartPhoneâ
â Add the below abstract methods
â int call(int seconds)
â void sendMessage()
â void receiveCall()
â Add non abstract method void browse()
â print âSmartPhone browsingâ inside browse() method definition
â Have constructor as below.
public SmartPhone()
{
System.out.println(âSmartphone under developmentâ);
}
2) Create class called âFactoryDemoâ as abstract subclass of SmartPhone
â Add the below abstract methods
â void verifyFingerPrint()
â void providePattern()
â Add non abstract method void browse()
â print âFactory Demo browsingâ inside browse() method definition
â Add variable boolean isOriginalPiece and assign âfalseâ as value.
â Add static variable int price and set value as 0.
3) Create class called âSamsungâ with main method as sub class of FactoryDemo.
â Add unimplemented methods
â Add static variable int price and set value as 5000.
â Create instance for Samsung class called sam
â Access browse() method using sam instance.
â Access price variable using sam instance.
â Observe which method is called and note down.
programe--
package task;
public abstract class Smartphone {
public void browse()
{
System.out.println("smart phone browsing");
}
public abstract int call(int seconds);
public abstract void sendMessage();
public abstract void receiveCall();
public Smart_Phone()
{
System.out.println("Smartphone under development");
}
}
package task;
public abstract class FactoryDemo extends Smartphone
{
boolean OriginalPiece = false;
static int price = 0;
public abstract void verify_finger_print();
public abstract void provide_pattern();
public void browse()
{
System.out.println("Factory demo Browsing");
}
@override
public int call(int seconds) {
// TODO Auto-generated method stub
return 0;
}
@override
public void sendMessage() {
// TODO Auto-generated method stub
}
@override
public void receiveCall() {
// TODO Auto-generated method stub
}
}
package task;
public class Samsung extends FactoryDemo{
static int price = 5000;
public Samsung(int price)
{this.price = 5000;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Samsung sam = new Samsung(5000);
sam.browse();
sam.price(5000);
}
@Override
public void verify_finger_print() {
// TODO Auto-generated method stub
}
@Override
public void provide_pattern() {
// TODO Auto-generated method stub
}
public void price(int price)
{
System.out.println(price);
}
}
output----
Factory demo Browsing
5000
Featured ones: