Computer Science 3675
Fall 2017
Practice Questions for Quiz 6

  1. Are all object-oriented programming languages statically typed? Answer

  2. Is a class an important concept of object-based programming? Answer

  3. In object-oriented programming language implementations, are methods stored in objects? Answer

  4. In a single-inheritance object-oriented language, is there a limit on the number of base classes that a class can have? Answer

  5. In a single-inheritance object-oriented language, is there a limit on the number of subclasses that a class can have? Answer

  6. In a single-inheritance object-oriented language, is there a limit on the number of superclasses that a class can have? Answer

  7. In object-oriented programming, is a private variable of an object accessible only to that one object, or is it possible for other objects to access it directly? Answer

  8. In object-oriented programming, you imagine that objects carry methods with them. Yet, the methods are not really stored with the objects. How does an object locate its methods? How does it know which methods to select? What is the name of the system support that is responsible for locating methods? Answer

  9. How does the mechanism for inheriting variables work in single-inheritance object-oriented languages? Answer

  10. What are the characteristics of a virtual method? What makes it virtual? Answer

  11. What is an abstract class? Answer

  12. What is the difference between static method selection and dynamic method selection? Answer

  13. True or false?

    1. A token can only have one associated lexeme. Answer

    2. A variable name is typically a single lexeme in a program. Answer

    3. Most programming languages have a comment token in their grammars. Answer

    4. Most programming languages require two consecutive lexemes to be separated by a space or spaces. Answer

  14. What is Backus-Naur Form, and what is it used for? Answer

  15. Show a parse tree for string aacacab according to the following grammar, where the start nonterminal is S. In this grammar, upper case letters are nonterminals and lower case letters are tokens.

        S → F a S
          | b
    
        F → a F
          | c
    

    Answer

  16. Show that the following grammar is ambiguous. The start symbol is S. Upper case letters are nonterminals and lower case letters are tokens.

        S → S a
          | a S
          | a
    

    Answer

  17. Consider the following BNF grammar.

        S → a S a
        S → b S b
        S → c
     
    Show that string abbcbba can be derived from S by showing a parse tree for it. Answer

  18. Write a context-free grammar for sequences of left and right parentheses that are balanced. A sequence of parentheses is balanced if parentheses match and are well nested. For example, (()(())) is balanced, but )( and ())()( are not balanced. The grammar must derive all balanced sequences of parentheses and must not derive any other sequences. Answer

  19. Write a context-free grammar for sequences of zero or more b's separated by commas. For example, it should derive b,b,b,b The grammar should not derive b,, or similar sequences that are not zero or more b's separated by commas. Answer