Você está na página 1de 2

Object-Oriented Using Java

Object-oriented programming concepts


Answer the following questions. 1. What is the purpose of keyword new? Explain what happens when this keyword is used in an application. 2. What is a default constructor? How are an object's instance variables initialized if a class has only a default constructor? 3. Explain the purpose of an instance variable. 4. Explain why a class might provide a set method and a get method for an instance variable. 5. Explain the notion of package access in Java. Explain the negative aspects of package access. 6. What happens when a return type, even void, is specified for a constructor? 7. Discuss the ways in which aggregation/ composition promotes software reuse, saves time during program development and helps prevent errors. 8. Discuss the ways in which inheritance promotes software reuse, saves time during program development and helps prevent errors. 9. Some programmers prefer not to use protected access, because they believe it breaks the encapsulation of the superclass. Discuss the relative merits of using protected access vs. using private access in superclasses. 10. How does polymorphism enable you to program "in the general" rather than "in the specific"? Discuss the key advantages of programming "in the general." 11. A subclass can inherit "interface" or "implementation" from a superclass. How do inheritance hierarchies designed for inheriting interface differ from those designed for inheriting implementation? 12. What are abstract methods? Describe the circumstances in which an abstract method would be appropriate. 13. How does polymorphism promote extensibility? 14. Discuss four ways in which you can assign superclass and subclass references to variables of superclass and subclass types. 15. Compare and contrast abstract classes and interfaces. Why would you use an abstract class? Why would you use an interface?

Review Question

Asia Pacific Institute of Information Technology

Page 1

Object-Oriented Using Java

Instance variables are any variables, without "static" field modifier, that are defined within the class body and outside any class's methods body. Package access allows a class, method, or variable to be accessible within the same package. Package access does not promote good OOP when applied to an instance variable because it destroys the notion of information hiding.

Review Question

Asia Pacific Institute of Information Technology

Page 2

Você também pode gostar