References


Self-Test Questions

1. 

Define the term problem abstraction. Explain why problem abstraction requires creativity.

image from book

2. 

What is the end result of problem abstraction?

image from book

3. 

Describe in your own words how you would go about the problem abstraction process for a typical programming problem.

image from book

4. 

What is the purpose of the UML class diagram? What geometric shape is used to depict classes in a UML class diagram? Where are class names, fields, and methods depicted on a class symbol?

image from book

5. 

What do the lines tipped with hollow arrowheads depict in a UML class diagram?

 - generalization/specialization relationship between base and derived class

6. 

List the four categories of Java class members.

 - static fields, static methods, instance fields, instance methods

7. 

Explain the difference between static and non-static fields.

image from book

8. 

Explain the difference between static and non-static methods.

image from book

9. 

What are the alternative names used to denote static and non-static fields and methods?

 - static (class); non-static (instance)

10. 

List and describe the three access modifiers.

 - public, protected, private

11. 

Explain the concept of horizontal access. Draw a picture showing how client code access to a server class’s fields and methods is controlled using the access modifiers public and private.

image from book

12. 

What is the purpose of data encapsulation? How can data encapsulation be unwittingly violated?

image from book

13. 

What is a method?

 - a methods is a named module of executable program functionality.

14. 

List and describe the desirable characteristics of a method.

 -a method should be well-named, maximally cohesive, and minimally coupled

15. 

Explain the concept of cohesion.

 - a method is cohesive if it has a well-focused purpose and pulls no surprises.

16. 

(True/False) A method should be maximally cohesive.

image from book

17. 

What steps can you take as a programmer to ensure your methods are maximally cohesive?

image from book

18. 

What’s the purpose of a method definition?

 - to declare and implement a method

19. 

What parts of a method definition are optional?

 - method modifiers, return type, parameter list, throws clause

20. 

What is meant by the term method signature?

image from book

21. 

What parts of a method are included in a method’s signature?

 - its name and number and type of its parameters

22. 

What constitutes an overloaded method?

image from book

23. 

Give at least one example of where method overloading is useful.

 - when a method performs similar operations on different data type parameters

24. 

What makes constructor methods different from ordinary methods?

 - constructors have no return type

25. 

Describe in your own words how arguments are passed to methods.

 - arguments are passed by value (copy) to all java methods.

26. 

(True/False) In programming situations that call for an object of a certain type, methods that return that same type can be used.

image from book

27. 

What’s the purpose of a static initializer?

28. 

How many static initializers can there be in a class definition?

Answers

1. 

- The process of selecting the essential elements of a problem with an eye towards modeling them in software. Problem abstraction requires creativity on the part of the programmer because you must analyze the problem at hand, extract its essential elements, and model these in software. Also, the process of identifying what abstractions to model may entail the creation of software entities that do not have a corresponding counterpart in the problem domain.

2. 

- The end result of problem abstraction is the identification and creation of one or more new data types. These data types will interact with each other in some way to implement the solution to the problem at hand.

3. 

- Identify problem domain objects or entities and their interactions. Create corresponding software data types that implement the required behavior.

4. 

- To express the static relationship between application classes. The rectangle shape is used to represent a class in the UML. The class shape is divided into three boxes. The topmost box contains the class name; the next box down contains names of class attributes; the lower box contains class method names.

5. 

- generalization/specialization relationship between base and derived class

6. 

- static fields, static methods, instance fields, instance methods

7. 

- all instances of a class share one copy of a static field; each instance has its own copy of a non-static (instance) field

8. 

- a static method can only operate on static fields; a non-static (instance) method can operate on both static and instance fields

9. 

- static (class); non-static (instance)

10. 

- public, protected, private

11. 

- Horizontal access denotes a client-server relationship between one class and another. The client class should only access the server class functionality via public methods. (Its public interface.)

12. 

- The purpose of data encapsulation is to hide class implementation details behind a set of public interface methods. It can be violated by returning a reference to an object’s field.

13. 

- A methods is a named module of executable program functionality.

14. 

-a method should be well-named, maximally cohesive, and minimally coupled

15. 

- A method is cohesive if it has a well-focused purpose and pulls no surprises.

16. 

- True

17. 

- Give the method a good name that accurately reflects its purpose. Give it a focused behavior that implements the action indicated by its name.

18. 

- To declare and implement a method

19. 

- method modifiers, return type, parameter list, throws clause

20. 

- a distinguishing characteristic exhibited by all methods that the compiler and java runtime use to resolve method usage within a program

21. 

- its name and number and type of its parameters

22. 

- A method with the same name but different signature. (i.e., differs in the number and type of its parameters)

23. 

- When a method performs similar operations on different data type parameters

24. 

- constructors have no return type

25. 

- Arguments are passed by value (copy) to all Java methods.

26. 

- True




Java For Artists(c) The Art, Philosophy, and Science of Object-Oriented Programming
Java For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504052
EAN: 2147483647
Year: 2007
Pages: 452

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net