1. What are the diagrams defined in the UML Standard. Give a one or two sentence description of each one.

2. Given the following code, how should the toString methods in the classes H2ClassA and H2ClassB be written to give the indicated output and take advantage of the natural toString method in H2ClassB?

3. How can the following code be corrected? Give at least two good answers.

4. Why does the following code give a compiler error? How should it be fixed?

5. What is wrong with the following declaration? How should it be fixed? public static final int myNumber = 17.36;

6. What is wrong with the following code? How should it be fixed?

7. What is wrong with the following code? How should it be fixed?

8. What is wrong with the following code? x should be given a value of 24. What are two ways this can be legally accomplished?

9. What is wrong with the following code? Give two effective ways to fix it.

10. Why does the following code give a compiler warning? How should it be fixed?

11. Pick an interface in the JDK and describe a good use of it. Java 8 stuff - I will probably be adding to this as we go along since 8 has so many new features.

  • Interface Default Methods in Java 8 | Javalobby
  • Lesson: Interfaces and Inheritance (The Java Tutorials > Learning the Java Language)

Also, I think you will find some of my thoughts and examples of interfaces helpful:

  • Musing A - Java Stuff - Intefaces survey
  • Musing A - Java Stuff - an extended example using applets
  • Tutorial on interfaces, Part 1 - Abstract, new Interfaces, Event Handling - pdf
  • Tutorial on interfaces, Part 2 - Vector class, sorting and collections - pdf

12. Choose one among the options below:

  • Make a proof (even informal) of the (nlgn) lower bound for sorting.
  • Are there any improvements on quicksort to avoid the O(n2) worst case? If so, specify and justify.
  • Insertion sort has an improved version: binary insertion sort. Briefly present the method (even informal). What is it improving? Explain.
  • Shell sort is a generalization of insertion sort. Briefly present the method (even informal) and justify why it is performing better than insertion sort.
  • Stability is a characteristic sometimes required for a sorting algorithm. It refers to preserving the relative order of equal elements in the output sequence. As discussion topic make the stability analysis of a sorting algorithm (at your choice), with justification.
  • Insertion sort is an efficient (yet not optimal) among the direct sorting methods. It is an effective approach when the data size is small. Justify.
  • Quicksort as its name suggests is a fast algorithm (and belongs to Hoare). Although its worst case is still O(n2), this case occurs very seldom. Justify.
  • Quicksort is not a good choice for small data sets, as the overhead for the recursive calls on useless subsets (such as empty data sets or 1 to 2 size sets) exceeds the actual sorting time. So, the quicksort algorithm may be combined with some direct sorting method when the algorithm reaches small sizes (below a predefined threshold). Provide such an enhancement for the quicksort algorithm.

13. The scope rules of modern programming languages are rooted in rules developed by the earliest block structured languages like Algol. Adding object orientation to languages adds one more layer of complexity to this issue.

Let's consider Java, a language with which everyone should be familiar, and explore its scope rules. One aspect of the scope rules of any language is when data or methods can have the same name. Give examples in Java to illustrate a case where declaring two local variables with the same name in same method is permitted and one where it is prohibited. Are the rules governing redeclaration of local names the same as those governing redeclaring local names that rename class-level names?

One consequence of scope rules in most languages is that forward references (referring to names before they are declared) are prohibited. Are such forward references always prohibited within a single Java class? Are forward references of local names always prohibited within a single method? If not, provide an example that demonstrates your claim.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.