RU beehive logo ITEC Department logo
ITEC 120
2007spring
ibarland,
jpittges

homeinfoexamslectureslabshws
RecipeLawsliessyntaxjava.lang docsjava.util docs

exam2-study-questions
exam2 study sheet

Exam2 will be given be during class on Apr.03 (Tue). It will consist of questions very much like these or questions, the quiz2 study questions, and perhaps a few similar to the book's study questions for Chapters 5-7. Some of the questions will be exactly from here, lab, quiz2-study-questions, or Chapters 5-7.

Study Sheet -- you can bring one page of notes to the exam: hand-written (no machine reproduction in any way), single-sided, 8.5″x11″


The material from Exam1 won't be especially tested, but due to the cumulative nature of the material, you should know all the topics from the exam1 study questions. In addition, you will need to know syntax for the if statment (and its variants), and for-each loops. Know the difference between == and .equals.

You will not need to know/use “import”, “static”, or classes such as java.io.File.

For the classes String, java.util.LinkedList<SomeType>, and the wrapper classes (Double, Boolean, etc.) you will not need to memorize the names of any of the methods or fields for those classes (beyond calling their constructor). However, if you are provided with documentation (for any of these classes or others), you should be able to create instances of that class and call its methods appropriately.

For these practice questions, feel free to discuss answers on the WebCT discussion board(s). Problems tagged as “[Challenge]” or “Optional” aren't necessarily difficult, but might rely on remembering details or concepts which weren't stressed. Such problems would be extra credit if they were on the test at all.

When giving a java expression or statement, you should be able to type it into BlueJ's Code Panel without any error; this means knowing where you need parentheses, where you need squirly-braces, and where you need semicolons (though I'll give some slack on these). I particularly recommend the problems which require actual code or definitions.

New Topics

Review Questions

  1. Review all homework, lab, and lecture questions.
  2. The exercises in Chapter 4 using for-each loop: 4.1-15, 23-38. (We have not talked about while-loops, iterators, or arrays1
  3. Create fields that hold the following linked lists
  4. For the lists above, write For Each loops to:
  5. Create a linked list of int
  6. Create a linked list of boolean
  7. An class's interface2 consists of all ____________ functions defined by a class
  8. Declare a List of... What are classes for the Container Classes lab which would naturally want such a list as one of their fields (perhaps in the place of other fields the lab used)?
  9. What is the value of (new String("cat") + new String("hay")) == new String("cathay")? Explain (1 short sentence).
  10. What is the value of (new String("cat") + newString("hay")).equals( new String("cathay") )? Explain (1 short sentence).
  11. What is the value of new String("cat") + (newString("hay").equals( new String("cathay") ))? Explain (1 short sentence).
    (What if we'd used the proper name "Cathay"? What if we'd called the method equalsIgnoreCase instead of equals?)
  12. The following code
    /** Change the input to be one bigger.
     * @param n the number to find the successor of.
     */
    void int successor( int n ) {
      n = n + 1;
      return n;
      }
    
    does not work as intended. (The cross-out version returns a value, and return the correct int.) In addition to not working, what rule-of-thumb is being broken?
  13. T/F: It is possible to write a method swapDoubles such that the last line below is true:
    double x = 5.0;
    double y = 7.0;
    swapDoubles( x, y );
    (x  == 7.0);
    
  14. Draw a picture of the object (and object references) involved during a sequence of calls to Dog's swapAge.
  15. Draw a picture of the object (and object references) involved during a sequence of calls to Cat's badClone method, and a working clone method, from lect09c.
  16. Draw pictures of what all the existing (references to) objects look like, after each of the following five lines, based on your hw04-soln (docs, code, test cases).
    Explorer me = new Explorer( "Dora" );
    Treasure t1 = new Treasure( "a singing map", "It guides you: over, around, and up.", 0.05, "");
    me.grab( t1 );
    me.grab( new Treasure( "a collideascope", "Like a kaleidoscope, but more dangerous.", 1, "" ) );
    me.dropLeft();
    
  17. Review all lab exercises, and problems mentioned on lecture pages (whether or not a solution is provided). Any of those problems are fair game for the exam.
  18. Write a function which takes in a non-empty LinkedList of… Use a for-each loop.

1nor (old-school) for loops, as separate from the for-each loop.      

2Meaning, how people can use this function. The term “interface” is also a (related-yet-different) Java keyword, which we'll talk about in the last week of class.      

homeinfoexamslectureslabshws
RecipeLawsliessyntaxjava.lang docsjava.util docs


©2007, Ian Barland, Radford University
Last modified 2007.Aug.27 (Mon)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme