There is a Banking application. It has 2 types of account,
Savings and Current. Write a method calculateInterest by
passing an ArrayList of these account objects and calculate
Interest accordingly. Write code for this situation



There is a Banking application. It has 2 types of account, Savings and Current. Write a method calc..

Answer / 94374

public class CalculateInterst {
public static double calculateInterest (List list){
double intrest = 0;
if(list != null && list.get(0).equals("SAVING")){
//Calculate interest for Saving Account and return it
intrest = 7.0;

}else if (list != null && list.get(1).equals("CURRENT")){
//Calculate interest for Saving Account and return it
intrest = 5.0;
}
return intrest;
}

public static void main(String[] args) {
List list = new ArrayList();
list.add("SAVING");
list.add("CURRENT");
calculateInterest(list);
}

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is assembly language?

0 Answers  


Question 6 [9] 6.1 In what situations (in general) would you use a TreeMap? (3) 6.2 In what situations (in general) would you use a HashSet to store a collection of values?

1 Answers  


How to convert string to byte array and vice versa?

0 Answers  


Difference between this() and super() ?

0 Answers  


Which collections are thread safe in java?

0 Answers  






What do you understand by overloading and overriding in java?

0 Answers  


In which order the iterator iterates over collection?

0 Answers  


What is == and === in javascript?

0 Answers  


What is the need of "creating and throwing an UserdefinedException" when the "Exception" class is already available?

4 Answers  


How does class forname work in java?

0 Answers  


What does a void function return?

0 Answers  


How to create two different thread class inside a main function?

1 Answers  


Categories