Define an interface Lockable containing functions- open() and close(). Define 2 classes, File and cupboard that implements Lockable interface with other details. Call the functions using the variable of Lockable. source file name: MediaDemo.java //interface Lockable have open().close() abstract methods interface Loc…
Read more5) Write a Java program that uses interface Controllable and two classes Television and Game .
Define an interface Controllable containing two functions- start() and stop(). Define 2 classes Television and Game that implements Controllable interface with other details. Call the functions using variable Controllable. source file name: LockDemo.java // interfaceControllable have start (),stop () abstract met…
Read more4) Write a Java program that uses interfaces ColdBlooded , OceanDwelling and classes Birds , Reptiles.
Interfaces are sometimes used to indicate which classes have a certain capability or characteristic. Consider the following classes and interfaces. The abstract class Animal has abstract subclasses named Bird and reptile. Classes Dove, eagle Hawk, Penguin and Seagull extend Bird. Classes Rattle Snake and Turtle exte…
Read more3) Write a Java program that uses several classes(Robot1, Robot2 and Robot3) and interface (Locomotion).
Write an application that combines several classes and interfaces. An abstract class Robot has concrete subclasses named RobotA, RobotB, RobotC. Class RobotA1 extends RobotA. Classes RobotB1 and RobotB2 extends RobotB. Class RobotC1 extends RobotC. The locomotion interface declares three methods name forward() and s…
Read moreinterface A { public void add(int a, int b); } interface B { public void sub(int a, int b); } class C implements A, B { void fact(int n) { int f=1; for(;n>0;n--) { f=f*n; } System.out.println("Factorial value "+f); } public void add(int a, int b) { System.out.println("add= "+(a+b)); } public …
Read moreclass A { void sqcube(int n) { int sq=n*n; int c=n*n*n; System.out.println("square "+sq+ " cube "+c); } } interface C { public void display(); } class B extends A implements C { void add(int a, int b) { System.out.println("add= "+(a+b)); } public void display() { System.out.println("…
Read more