What are the characteristics of a virtual method? What makes it virtual? Answer
What is an abstract class? Answer
What is the difference between static method selection and dynamic method selection? Answer
True or false?
What is Backus-Naur Form, and what is it used for? Answer
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
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
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
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
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