Answer any two questions from this section
Question one
Seafaring Ltd is running a promotion for all their customers. When a customer makes a purchase for electric goods the system awards the customer 10% of the purchase value as points. In reality, however, the customer is awarded 40% in points of the profit on that particular sale. Non-electric goods are not awarded any points. At the end of the promotion period customers who have accumulated over 1000 points will all be awarded random rewards. The management are concerned that this little trick they are using will be discovered when a customer called Mutua who is IT savvy comes calling. Write a program that will allow Mutua to enter all his sales for the month show him his points as 10% of purchase price but still award him points based on the 40% rule. i.e. what it displays and what it stores are different values.
(18 marks)
List and briefly describe three characteristics of effective encapsulation using suitable examples.
(7 marks)
Question two
List the access modifiers applicable to the following:
Class
Sub class
Package
World
(8 marks)
A simple library information system is supposed to store details about books. The program will check how many books a user has borrowed at a given time and check the following.
Number of books borrowed by the user
If the user has any books that have been out for more than 21 days they will pay a fine at the rate of ten shillings per day.
If the user has borrowed more than three books the program will display a message to that effect and not allow him to borrow.
Demonstrate this using a Java program (7 marks)
Question three
Define the term encapsulation and tight encapsulation. Hence demonstrate encapsulation using two programs of your choice, one showing tight encapsulation and the other normal encapsulation; make sure you use appropriate comments to differentiate the two types of encapsulation.
(7 marks)
Write a program that demonstrates how to get connected with a web server by using sock-getInet Address () method of net-socket class (you will need to import Java.net.*)
(8 marks)
For a custom-written paper on the above topic, place your order now!
What We Offer
• On-time delivery guarantee
• PhD-level professionals
• Automatic plagiarism check
• 100% money-back guarantee
• 100% Privacy and Confidentiality
• High Quality custom-written papers