Ask Question
14 April, 03:18

Create an application named TurningDemo that creates instances of four classes: Page, Corner, Pancake, and Leaf. Create an interface named ITurnable that contains a single method named Turn (). The classes named Page, Corner, Pancake, and Leaf implement ITurnable.

+3
Answers (1)
  1. 14 April, 03:56
    0
    1) TurningDemo

    public class TurningDemo

    { public static void main (String[] args)

    {

    Leaf obj1 = new Leaf ();

    Corner obj2 = new Corner ();

    Page obj3 = new Page ();

    Pancake obj4 = new Pancake ();

    } }

    2) ITurnable

    public interface ITurnable

    {

    public void Turn ();

    }

    3) Leaf class:

    public class Leaf implements ITurnable

    {

    }

    Page class:

    public class Page implements ITurnable

    {

    }

    Corner class:

    public class Corner implements ITurnable

    {

    }

    Pancake class:

    public class Pancake implements ITurnable

    {

    }

    Explanation:

    The first is TurningDemo application which creates instance obj1, obj2, obj4 and obj4 of four classes Page, Corner, Pancake, and Leaf. new keyword is used to create new object or instance of each class.

    The second is ITurnable interface. It contains a single method Turn () which is of type public.

    Thirdly, classes named Page, Corner, Pancake, and Leaf implement ITurnable. implements keyword is used to implement a interface so this interface can be used by these classes.

    These classes can also implement turn () of ITurnable interface as follows:

    Leaf class:

    public class Leaf implements ITurnable

    { public void turn ()

    {

    }

    }

    Page class:

    public class Page implements ITurnable

    {

    public void turn ()

    {

    }

    }

    Corner class:

    public class Corner implements ITurnable

    { public void turn ()

    {

    }

    }

    Pancake class:

    public class Pancake implements ITurnable

    { public void turn ()

    {

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Create an application named TurningDemo that creates instances of four classes: Page, Corner, Pancake, and Leaf. Create an interface named ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers