- Create a package called bank.chennai.
- Create a public class called ‘SBI’.
- Have default non-static variables String empName, empId.
- Have default static variable branch_name = ‘chennai’
- Create two default, non-static methods get_loan(int amount), create_account() with void as return datatype.
- Now, in the same package(bank.creditcard), create one more default class called Account_Holder.
- Have main method in this class.
- Try to access all static, non-static variables and non-static methods in SBI class.
- Create another package called bank.madurai.
- In this package, create default class called Account_Holder_Madurai.
- Have main method in this class.
- Try to access all static, non-static variables and non-static methods in SBI class.
- Note down the Errors and rectify those errors and make sure this class gives output without any error.
Source code:
package bank.chennai;
public class SBI
{
String empname,empid;
public static String branch_name="chennai";
public void get_loan(int money)
{
System.out.println("got loan money"+" "+money);
}
public void create_account()
{
}
}
Source code:
package bank.creaditcard;
import bank.chennai.SBI;
public class Account_holder extends SBI
{
public static void main(String[] args)
{
Account_holder acc=new Account_holder();
acc.create_account();
acc.get_loan(10000);
System.out.println(SBI.branch_name);
}
}
Source code:
package bank.madurai;
public class Account_holder_madurai
{
String empname,empid;
public static String branch_name="chennai";
public void get_loan(int money)
{
System.out.println("got loan money"+" "+money);
}
public void create_account()
{
}
}
Top comments (0)