Appendix G: Object-Oriented Programming with Java 6. How is a redefined method introduced into a Java subclass? 7. The Java keyword abstract has two uses. Give examples of each and explain their usage. 8. Answer the following, giving explanations. (a) Can an interface extend another interface? (b) Can an interface extend more than one interface? (c) Can an interface subclass an abstract class? (d) Can an abstract class extend another abstract class? (e) Can a concrete class extend an interface? (f) Can a concrete class implement an interface? (g) Can a concrete class implement two interfaces and extend an abstract class? (h) Can a concrete class extend two abstract classes? 9. Develop a Person class with name and age properties. Now develop two specializations from class Person. Prepare the class Student as a subclass of Person with a matriculation number attribute. Revise the Employee class from this chapter with Person as its superclass. 10. Develop the class Employee with name and employee number attributes. Provide suitable methods for this class. Introduce into the class the abstract operation computeMonthlyPay that is redefined in the subclasses SalariedEmployee and HourlyEmployee. A salaried employee has a salary, which is paid out monthly. An hourly employee has a fixed pay rate and a number of hours worked per month. Implement the method computeMonthlyPay for these two subclasses. 11. Develop a class Account having a balance and account number attributes. Introduce the methods debit and credit that implement deposit and withdrawal transactions on a bank account. Form two specializations for the classes DepositAccount and CurrentAccount. A deposit account accrues interest and cannot be overdrawn while a current account may be overdrawn up to some overdraft limit. 12. Develop the concrete class Circle as a subclass of ClosedFigure. Test its behaviour using program G.4. 13. Develop the class Quadrilateral to represent any four-sided figure, then specialize this into the subclasses Rectangle and Square. Choose a suitable representation for the Quadrilateral and implement the operations getPerimeter and getArea. Redefine both these for the two subclasses. 14. Look up the Swing class Jframe in the Java documentation and present its super- class hierarchy. 15. Look up the Swing classes WindowListener and WindowAdapter in the Java documentation files. What is the class hierarchy of these two classes? Why is class WindowListener an interface? How is class WindowAdapter a concrete class?
If you looking for unlimited one inclusive web hosting plan please check cheap web hosting website.
This entry was posted
on Monday, January 5th, 2009 at 10:09 am and is filed under java jsp tomcat.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.