DEV Community

hema latha
hema latha

Posted on

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);

}
Enter fullscreen mode Exit fullscreen mode

}

output----
Factory demo Browsing
5000

Top comments (0)