Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA - how to do part c l:a: Using a simple example, discuss why casting a superclass reference to a subclass reference is potentially dangerous.
JAVA - how to do part c
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 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 AccountsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started