Practical No 6 Interface
Practical No 6 Interface
4. Q1) Write a program to define a user defined package Mypack in which you will write a
class Balance. The Balance will have data members as String Name, Double Balance.
Write a constructor to initialize the member. Write a function to display Name and
Balance. Now import this package in your class.
5. Q2) Create a package Animals. In package Animals create interface Animal with suitable
behaviors (move, eat). Define two classes Dog and Cat that implement Animals interface.
Now import this package in your class.
6. Q3) Define a package “Diagram” which contain the following:
7. Define an interface Shape containing function area. Define two classes Triangle and
Rectangle that implement Shape interface with proper code for calculation of area. Also
define a class to test the above and call the function area using variable of Shape.