Java代写,Java作业代写,Java程序代写,Java Final代写
INFO1113 Final Exam,Java Final代写,留学java代写
1. What will be output of the following program shown in Figure 1? Explain your answer.
2. The following Java program shown in Figure 2 returns compile time error. Identify all the 6 marks errors and correct them.
Do not write the entire program. Just mention the line numbers which are incorrect and then write the required changes in those lines to get the following output:
Android App Don’t show Ad
3. Suppose you had a linked list object, and you added the five numbers: 123, 456, 789, 658 and 527 in that order. What would be the output if you called the following method shown in Figure 3 on the head node of the linked list? Explain your answer.
4. Create a class GiftCard (Figure 4A) that represents a gift card for the purchase of books 9 marks
online. It should have the following private attribute: amount - the amount of money on the card
and the following public methods:
GiftCard(double amount) - a constructor to initialize the card
void buyBook(double totalPrice) - records the purchase of books by decreasing the amount of money used for purchase using this card and prints “Books bought successfully”. Print an error message if the gift card does not have sufficient amount to pay the totalPrice.
double amountRemaining() - returns the remaining amount of money in the gift card.
5. Create an interface called BasePolygon that has a default method called display() which 9 marks
simply prints “This is a Polygon”.
Create another interface called Polygon that extends BasePolygon interface and has an
abstract method calculateArea().
Create a class Rectangle that implements the interface Polygon. It has two private attributes height and width. The constructor has two parameters and initializes height, width with those parameters. Define the method calculateArea() so that it outputs the area of a rectangle.
6. Create a generic class called ShoppingCart
The ShoppingCart
addItem(N name, P price) to add an item to the shopping cart.
removeItem(N name) to remove an item from the shopping cart. If the item does not exist, print "
checkout() to print the list of items in the shopping cart
7. Write a java program to read the age of each person in a HashMap


