You are on page 1of 5

Classification: Internal

JAVA ASSIGNMENT 3

Exercise 1:

a) Create base class named Person


b) Properties: id, name , address
c) Add default constructor in Person class
d) Add constructor with three parameters id, name, address
e) create class Employee which inherits all the three properties id, name,
address
f) Add default constructor to employee class
g) add basicSalary property in Employee with getter and setter
h) create class EmployeeMain with main method
i) In main method create object of Employee
j) set all the properties id,name,address , salary calling setters of employee
k) display the Employee details

Exercise 2:

a) Using the above Exercise 1


b) Remove the default constructor form Person and employee classes
c) Modify Employee class add parameterized constructor to assign the
properties Person class
d) In EmployeeMain create an object of Employee class
e) assign the properties using Employee class parameterized constructor

(don’t use setter)

f) display the details of employee by calling getter form Employee class


Classification: Internal

Exercise 3:

a) Modify the Employee class add toStirng() method to represent the object
b) toString() method display id, name , salary, address
c) From main method instead of calling getter display the employee
object directly using System.out.println(empObj);

Exercise 4:

a) Modify Employee and Person class by adding default constructors


b) Modify the Employee class add two properties specialAllowance
houseRentAllounce (set default values set specialAllowance as 200.30 and
houseRentAllounce ( 2000 )
c) Add getter and setters for specialAllowance and houseRentAllounce

Exercise 5:

a) Create a method calculateEmpSalary in which the basic salary needs to be

calculated as below.

b) empSalary = basicSalary + ( basicSalary * specialAllowance/100) +

(basicSalary * houseRentAllounce/100);

c) The calculated salary should be displayed in the console

Exercise 6:

a) Create class Developer which inherits Employee properties


b) Create class Tester which inherits Employee properties
c) add parameterized constructor in Developer and Tester classes
to set the property to superclass
Classification: Internal

d) In EmployeeMain class main method create an object of Deveoper and


Tester class and display the information (use constructor to set the
properties )
e) Display the salaries for Developer and Tester on console)

Exercise 7:

a) Create an abstract class Shape which is having the abstract function draw ().
b) Create three more sub classes from Shape which is Circle, Triangle , Line
c) Override the display method inside all three classes printing a message
d) For circle => “draw a circle” Triangle->” draw a triangle” Line=> draw Line
e) Create DrawTestclass with entry point main
f) Take input form user 1 to 3
g) Give option for user 1 for Circle , 2 for triangle , 3 for Line obj

//use DrawTest templet

Public class DrawTest

Public static void main(String arg[])

Shape shape = null;

// add code to get user input and create object of circle , triangle , Line

//Depending on user input

}
Classification: Internal

Exercise 8:

a) Create Account class having


propertiesaccountId,branchNamemaxBbalanceLimit(50000)minBalanceLimi
t
b) Add methods withdraw() / deposit() / balanceCheck()
c) withdraw() and deposit() are abstract methods
d) balanceCheck() is concrete method
e) Create class SavingAccount class which inherits properties of Account class
f) create class CurrentAccount class which inherits properties of Account class
g) minBalancelimit for SavingAcountis 2000
h) minBalanceLimit for CurrentAccount is 5000
i) override the withdraw() and deposit() method in Saving and Current
account classes
j) Add logic to check min and max balance limit when the process is done
k) if the withdrawal() or deposit exceed the given limit then print proper
message to the user
l) Create class AccountMain with main entry point
m) Create object of SavingAccount and CurrentAccount make a call
towithdrawal and deposit and display the balance .

Exercise 9:

a) In the main method of AccoutMain class create a base class reference


Account myAccount=null
b) Using base class reference create object for the Saving and Current
Account class
c) Call the withdrawal and deposit process on these objects and display the
balance

Exercise 10:

a) Modify the above hierarchy and replace the Account class with IAccount
interface
Classification: Internal

b) In the main method of AccountMain class add code that invokes the Saving
and Current account process using the IAcount reference

Exercise 11:

a) Create interface named ILoan with two services loanRequst()


loanStatus()
b) Only saving account customers can request for the loan
c) If the saving account having balance more than 50000 thousand can apply
for loan
d) Approval for loan can be checked by loanStatus () which gives status as
“Loan approved” Or “Loan rejected’
e) In the main method of AccountMaincreate an object of Saving account
f) Add some deposit to the accountand request for the loan process
g) Check the status for the same

You might also like