Java Multi-Level Inheritance: Program Implementation

Write a program to implement the following Multi-Level Inheritance:
Class: Account
Cust_name , acc_no

Class: Saving_Acc
Min_bal, saving_bal

Class:Acct_Details
Deposits, withdrawals

import java.lang.*;
import java.io.*;
class Account
{
	String cust_name;
	int acc_no;
	Account(String a, int b)
	{
		cust_name=a;
		acc_no=b;
	}
	void display()
	{
		System.out.println ("Customer Name: "+cust_name);
		System.out.println ("Account No: "+acc_no);
	}
}
class Saving_Acc extends Account
{
	int min_bal,saving_bal;
	Saving_Acc(String a, int b, int c, int d)
	{
		super(a,b);
		min_bal=c;
		saving_bal=d;
	}
	void display()
	{
		super.display();
		System.out.println ("Minimum Balance: "+min_bal);
		System.out.println ("Saving Balance: "+saving_bal);
	}
}
class Acct_Details extends Saving_Acc
{
	int deposits, withdrawals;
	Acct_Details(String a, int b, int c, int d, int e, int f)
	{
		super(a,b,c,d);
		deposits=e;
		withdrawals=f;
	}
	void display()
	{
		super.display();
		System.out.println ("Deposit: "+deposits);
		System.out.println ("Withdrawals: "+withdrawals);
	}
}
class q9Multilevel
{
	public static void main(String args[])
	{
		Acct_Details A = new Acct_Details("Pa.one",666,1000,5000,500,9000);
		A.display();
	}
}

 

Rabins Sharma Lamichhane

Rabins Sharma Lamichhane is the owner of RabinsXP who is constantly working for increasing Internet of Things (IoT) in Nepal. He also builds android apps and crafts beautiful websites. He is also working with various social services. The main aim of Lamichhane is to digitally empower the citizens of Nepal and make the world spiritually sound better both in terms of technology and personal development.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: