Program to implement the Multiple Inheritance (Bank Interface, Customer & Account classes)
In this program, we have achieved multiple inheritance using interface. We have created an interface Bank having data members rate, no_of_years and method show( ). After that class Customer is created which has data members cust_name, cust_id and method display( ). Finally we declare the Account class having data members acc_no, acc_bal and method interest( ). In that we have extended Customerclass and implemented Bank interface as shown in program.
PROGRAM
PROGRAM
/* Program to implement the Multiple Inheritance */
interface Bank {
float rate = 12.0f;
int no_of_years=3;
void show();
}
class Customer {
String cust_name;
int cust_id;
Customer(String n,int i) {
cust_name = n;
cust_id = i;
}
void display() {
System.out.println("Customer Name = "+cust_name);
System.out.println("Customer Id = "+cust_id);
}
}
class Account extends Customer implements Bank {
int acc_no;
float acc_bal;
Account(String n,int b,int x,float y) {
super(n,b);
acc_no=x;
acc_bal=y;
}
public void show() {
display();
System.out.println("Account No. = "+acc_no);
System.out.println("Account Balance = "+acc_bal);
}
void interest() {
show();
float intr = (rate*acc_bal*no_of_years)/100;
System.out.println("Interest = "+intr);
}
}
public class Acct_Details {
public static void main (String[] args)
{
Account ac = new Account("Sameer",8,4052,5000);
ac.interest();
}
}
OUTPUT
C:\>javac Acct_Details.java C:\>java Acct_Details Customer Name = Sameer Customer Id = 8 Account No. = 4052 Account Balance = 5000.0 Interest = 1800.0
ty
ReplyDeleteGood But you try give input user.
ReplyDeleteI wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. Walmart Customer Service
ReplyDeleteI haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. Syndicate bank customer care
ReplyDeleteIn the event that you are in the United States, a bank in Singapore is a seaward bank to you. In this manner, the possibility of seaward banking is relative.
ReplyDeletechase routing number
Thank you so much for this information. wells fargo routing number mn
ReplyDelete