Question: l:a: Using a simple example, discuss why casting a superclass reference to a subclass reference is potentially dangerous. 5 MARKS b: What is the difference

 l:a: Using a simple example, discuss why casting a superclass reference

l:a: Using a simple example, discuss why casting a superclass reference to a subclass reference is potentially dangerous. 5 MARKS b: What is the difference between abstract classes and interfaces? Do all the methods in an abstract superclass have to be declared as abstract? 5 MARKS c: Consider the inheritance hierarchy of Figure 1 below. For each class, indicate the common attributes and methods consistent with the hierarchy. Assume that a CurrentAccount provides overdraft facilities and that a StudentAccount is similar to a Current Account but has no transaction charges. Write simple Java implementations for each of the classes shown including constructors and other methods required. The base Account class should be declared as an abstract class of Transaction objects i.e. define a class called Transaction suitable for this purpose 5 MARKS Account CurrentAccount SavingsAccount LoanAccount StudentAccount Figure 1 -Inheritance Hierarchy for Bank Accounts

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!