+ Link For Assignments, GDBs & Online Quizzes Solution


+ Link For Past Papers, Solved MCQs, Short Notes & More

Assignment No. 02
SEMESTER Spring 2016
CS508- Modern Programming Languages


Total Marks: 20


Due Date: 20/07/2016


Please read the following instructions carefully before solving & submitting assignment:

It should be clear that your assignment will not get any credit  if:

  • The assignment is submitted after due date.
  • The submitted assignment does not open or file corrupt.
  • The assignment is full or partially copied from (other student or ditto copy from handouts or internet).
  • Student ID is not mentioned in the assignment File or name of file is other than student ID.
  • The assignment is not submitted in .doc or .docx format.

Uploading instructions

Your submission must include:


  • Assignment should be in .doc or .docx format.
  • Save your assignment with your ID (e.g. bx020200786.doc).

Assignment submission through email is NOT acceptable


The objective of this assignment is


  • To be able to understand different concepts of JAVA programming language.



Your answer must follow the below given specifications.

  •  Font style: “Times New Roman”
  •  Font color: “Black”
  •  Font size: “12”
  •  Bold for heading only.
  •  Font in Italic is not allowed at all.
  •  No formatting or bullets are allowed to use.
  • Your answer should be precise and to the point, avoid irrelevant detail.


Lectures Covered: This assignment covers Lecture # 27 - 30


Your assignment must be uploaded/submitted at or before 20/07/2016.



Question:           20 marks     


JAVA is purely object oriented programming language which means every variable, constant and function (method) including main function must be in some class. Furthermore, Java support only single inheritance and each supper class method except its constructors can be inherited, overloaded, or overridden in the subclass.


You are required to write a JAVA program which contains the following three classes.

  1. Bank_accounts   (Base class)
  2. Saving_Account (Subclass of Bank_accounts)
  3. Saving_Acc_Test (main function class)

The base class Bank_accounts should define the attributes/variables for account title, Balance, interest (interest should be in amount).

The base class must contain the methods Withdraw(), Deposit() and add_interest().


The subclass Saving_Account should define an attribute for interest rate (Annual interest  in percentage). This class should inherit Withdraw() method, overload Deposit() method and override add_interest () method of base class. Furthermore, the deposit method should deposit some interest (in percentage) on each deposit to saving account and add_inerest method should calculate annual interest on the basis of interest rate.


Saving _Acc_Test class should have main function and define one object of Saving_Account class and one reference of Bank_accounts class pointing to Saving_Account class object, then call these methods of base class and subclass to implement the concept of inheritance, overloading, overriding and polymorphism.


You may add constructors and getter/setter functions in your classes as per your requirements.


Hint:  You may set any value for initial balance and deposit/withdraw any amount through these methods. Furthermore, you may call deposit method of base class with derived class object, overloaded deposit method with this object, and withdraw method to implement inheritance and overloading. Similarly call the override method with base class reference to implement overriding and polymorphism.


Note 1: You can compile/check your program online through the link http://www.ideone.com/  for syntax errors.


Note 2: Once you complete assignment, upload your code in a single MS word (.doc or .docx) file on VULMS.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Views: 2134

Replies to This Discussion

is me error han, 

is net beam pr ni chaal raha..

Is ki main class b chahyee... 

plz full correct solution ki zip file agr dy do to...

class Bank_accounts {
protected String accountTitle;
protected double balance = 700;
protected double interest = 0.0;

public String getAccountTitle() {
return accountTitle;
public void setAccountTitle(String accountTitle) {
this.accountTitle = accountTitle;
public double getBalance() {
return balance;
public void setBalance(double balance) {
this.balance = balance;
public double getInterest() {
return interest;
public void setInterest(double interest) {
this.interest = interest;
public void withdraw(double amnt){
balance = balance - amount;
void deposit(double amount){
balance = balance + amount;
void add_interest(){
interest = 20.0;
class Saving_Account extends Bank_accounts{
private double annualInterestRate = 0.0;

public double getAnnualInterestRate() {
return annualInterestRate;
public void setAnnualInterestRate(double annualInterestRate) {
this.annualInterestRate = annualInterestRate;
void deposit(double amount, double intrst){
interest = interest + (amount * (intrst/100));
balance = balance + amount;
void add_interest(){
annualInterestRate = (interest *12)/100;

class Saving_Acc_Test {

public static void main(String args[]){
Bank_accounts b = new Bank_accounts();
b.accountTitle = "Ali Zaman";

System.out.println("Account Title" + b.getAccountTitle());
System.out.println("Initial Balance " + b.balance);
System.out.println("Balnance after deposit and withdraw transaction for account " + b.getAccountTitle()+" :" + b.getBalance());

Saving_Account s = new Saving_Account();
s.accountTitle = "Sheraz Hussain";
double bal = s.getBalance() + (s.getBalance() *s.getAnnualInterestRate() );
System.out.println("Account Title" + s.getAccountTitle());
System.out.println("Initial Balance " + s.balance);
System.out.println("Balnance after getting annual Interest " + bal);


Looking For Something? Search Below

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service