Programing Languages -- The Language of Love

  1. Valentines day
    1. Lasts 24 hours
    2. Lasts too long
    3. Is a life to be lived daily
  2. Which method produces the fastest program?
    1. Write in machine language or assembly?
    2. Write in C++
    3. Write in Java
    4. Write in Perl
  3. Recognizing that  the "<" and "+" symbols together produce the "less that or equal to operator" is done by
    1. The lexical analyzer
    2. The language grammer
    3. The semanics of the programming langauge.
  4. What is "3 4 + 1 5 * +"? ________________________
  5. What is "+ 3 * 2 1 + 4" _________________________
  6. (Three points)  Write me a grammer that matches all pathnames in a filesystem.  It should match "/",  "/heart" "/heart/love/mooshy" but NOT "/cuddle/" and not "/love//hurts"










  7. (Two points) Here is a grammer.  Parse the two inputs based on this grammer.
    test := expression "==" expression                         Input #1:      3 + 4 = 2 * 5 + 3
    expression := factor * term | factor                         Input #2:      2  = 3 * 5 * 2 
    factor := term + term | term
    term := "(" expression ")" | number






  8. In the grammer above, which has higher precedence, "+" or "*"? ___________________
  9. I'm a compiler.  I want to implement a case statement.  My case statement has choices 1,2,3,4,5,6,99999999999.  Which method should I use?
    1. Jump table
    2. Bunch of if's (conditionals)
    3. Hash table
  10. What does this program in C++ print?
    main() {
        for(int i = 0; i < 3; i++)  {
                  continue;
                  cout << "Bunny foo-foo!\n";
         }
    }
  11. Does this program fragment generate a divide-by-zero error?
    int a = 0;
    if (10 / a == 3 && a != 0) cout << "Sweatheart\n";
  12. There are two ways to store a string.  Char's followed by  zero or length followed by chars.  Give one string operation (besides count-the-length) that is faster with the second type than the first.
    _____________________________________________________________________________________
  13. I have a Java array declared as 'int boyfriendmap[10][20][30].  The array starts at location 10,000.  Where is a[3][2][4]? _____________________________
  14. What does this code print using call-by-value? _____________  Call by reference? ____________________
    int g1 = 1;
    main() {
         int g2 = 2;
         cout << sweetums(g1, g2):
    }
    int sweetums(int a) {
         a = a * 3;
         return a + g1;
    }
  15. Which of these things appears in an activation record on the stack during a procedure call?  Choose all that apply.
    1. Local variables to the procedure being called
    2. Global variables to the program
    3. The program counter where the caller was when he called.
    4. The program counter where the callee is in his code.
  16. How many bytes does Smooch take in Java?  Assume that Kiss needs 20 bytes.
    class Smooch extends Kiss {
         float severity;
         int location;
         void print() { System.out.println("Smoch!"); }
    }
  17. Given the classes below, does Squeeze have a field 'location'?  ____________ What line would assign 12 to 'length' of an instance name 'fred' of Squeeze ____________

  18. class Squeeze extends Hug {
         public boolean mixbreathes;
    }
    Class Hug extends Touch {
         protected int length;
    }
    Class Touch {
         private int location;
    }
  19. Connect the word and the concept.  Everything gets ONE partner

  20. C++                                            Can be used to implement a 'increment' function
    Java                                           Interpreted
    Pass By Reference                              Array bounds checking
    Pass By Value                                  Virtual Functions

    Helps Catch Errors                             Used for small data items in C++
    Faster                                         Compiled
    Slower                                         Non-Virtual Functions
    Love                                           Candy Samples
  21. You're too close when
    1. You can finish each others sentences.
    2. She makes you lunch.  Daily.
    3. You're toothbrush is at her apartment.
    4. You take bathes to get some alone time.
    5. You cannot sleep without her cute little snores.
  22. In der Grosste Abreitsverugn, welche Panzerkampfwagen ist kaput?
    1. Helmut Kohl
    2. Ryan Dieter
    3. Sprokets!!!
  23. Spoken Question:  How are virtual functions implemented?