Hello! I'm doing my first homework assignment with abstract classes and interfaces.
I have a few questions:
(1) I know that a class must be saved on the computer as, for example, Class.java. Is this the same for abstract classes? How are interfaces supposed to be saved? Do they need to be in the same folder or anything as the classes that implement them?
(2) I'm writing a class that simulates a bank account, including an online transfer between two accounts. To make it realistic, I'm having the class ask for the account number, amount, and purpose for the transfer, even though that doesn't influence the calculation involved in the transfer. For that, I obviously need to introduce a scanner - does that sort of thing get written in the interface as well? The scanner will be used in the main method for the bank account class, so I was thinking not - as the main method isn't written in the interface normally. I'm just not sure, and I thought maybe someone could explain that!
(3)This may be an idiotic question, but I'll ask it nonetheless. If I want to print an object and I already have a print() method, I can type
object.print()
to do just that. However, what if I have a method that takes in a certain variable (such as
calculateTransfer(double transfer)
) ? When I call that method, do I write:
transfer.calculateTransfer();
or should it be:
transfer.calculateTransfer(double transfer)
That seems like overkill, but - I'm just not sure. The lecture for this class is all about the history of Java, and all of the homework assignments are kind of a free-for-all, hope-you-find-all-the-information-you-need assignments. So, basically, thank you so much in advance!