OBJECT ORIENTED PROGRAMMING USING JAVA

QUESTION BANK

  1. Write a program to display “hello world”.

  2. Write a program that shows the use of bit wise operators.

  3. Write a program that shows the use of arithmetic operators.

  4. Write a program that shows the use of increment and decrement operators.

  5. Write a program to display the area of circle using (i)command line argument, (ii)Scanner class (iii) BufferedReader class

  6. Write a program to display the addition result of any two integers.

  7. Write a program for the swapping of two numbers.

  8. Write a program to print all the prime numbers between 1 to 100.

  9. Write a program to print all the palindrome number between 100 to 500.

  10. Write a program to display the student name, roll no and age of a student using class and object concept.

  11. Write separate programs that shows the implementation of

(i)static variable and static member function

(ii)static block concept

  1. Write a program that shows the use of default, parameterized and copy constructor.

  2. Write separate programs for method overloading and method overriding mechanism.

  3. Write a program for single inheritance mechanism.

  4. Write a program where abstract class concept is used.

  5. Write a program to pass the arguments from child class constructor to parent class constructor using super ( ).

  6. Write a program to display name, department and age of employee using interface mechanism

  7. Write a program for the implementation of user defined package.

  8. Write a program for the manipulation of string using different functions of String class.

  9. Write a program for the execution of multiple threads with their priority.

  10. Write a program for the execution of multiple threads.

  11. Write a complete program for the execution of applet mechanism.

  12. Write a program for drawing several GUI components on applet.

  13. Write a program for the implementation of several methods of Graphics class.

  14. Write a program for handling multiple exceptions.

  15. Write a complete program for Java Database Connectivity.

  16. Write a program to enter two numbers(say a and b) and an option. If the option is:

1:display the result (a+b)

2: display the result (a-b)

3: display the result (a*b)

4: display the result (a/b)

5: display the result (a%b)

  1. Write a program to display emp. no=101 and emp. name=”Martin” using class and object concept.

  2. Write a program to display the area of triangle, rectangle and circle using constructors.

  3. Write a program to print all the armstrong numbers between 200 to 400.

  4. Write a program to check whether a number is prime or not.

  5. Write a program to check whether a number is armstrong or not.

  6. Write a program to check whether a number is pallindrome or not.

  7. Develop a menu based program for the addition, subtraction, multiplication and division of two complex numbers.

  8. Write a program for the addition, subtraction, multiplication and division of two numbers using constructor.

  9. Write a program for addition of two 3x3 matrix.

  10. Write a program for multiplication of two 3x3 matrix.

  11. Write a program to display the transpose of a 3x3 matrix.

  12. Write a program to display the sum of digits of a number.

  13. Write a program to display the reverse of a number.

  14. Write a program to enter n numbers to an array and display the greatest and smallest number.

  15. Write a program that shows the use of multilevel inheritance mechanism.

  16. Write a program that shows the use of multiple inheritance mechanism using interface.

  17. Write a program todisplay car no., model, color and price of a car using class and object concept.(use Scanner class)

  18. Write a program to display the area of circle, triangle and rectangle using user defined package

  19. Write a program to display the name, pages, price and author of a book using interface mechanism.

  20. Write a program to display the average of five integers.

  21. Write a program to display simple interest.

  22. Write a program to display the factorial of a number.

  23. Write a program to display the fibonacci series upto n terms.

  24. Write a program to enter two numbers and display the GCD and LCM.

  25. Write a program to convert decimal number to binary number.

  26. Write separate programs for different pyramid structures.

  27. Write a program for the implementation of swing components.

  28. Write a java socket programming in which client sends a text and server receives it.

  29. What are the OOP Principles?

  30. What is Encapsulation?

  31. What is Polymorphism?

  32. What is Inheritance?

  33. What are the features of Java Language?

  34. What is the need for Java Language?

  35. What is platform independency?

  36. What is Architecture Neutral?

  37. How Java supports platform independency?

  38. Why Java is important to Internet?

  39. What are the types of programs Java can handle?

  40. What is an applet program?

  41. Compare Application and Applet.

  42. What are the advantages of Java Language?

  43. Give the contents of Java Environment (JDK).

  44. Give any 4 differences between C and Java.

  45. Give any 4 differences between C++ and Java.

  46. What are the different types of comment symbols in Java?

  47. What are the data types supported in Java?

  48. What is the difference between a char in C/C++ and char in Java?

  49. How is a constant defined in Java?

  50. What is the use of final keyword?

  51. What are the different types of operators used in Java?

  52. What is short-Circuit operator?

  53. What is labeled break?

  54. What is the use of for each control structure?

  55. What is the need for static variables?

  56. What is the need for static methods?

  57. Compare static constants and final constants.

  58. Why is main method assigned as public?

  59. Why is main method assigned as static?

  60. What are the types of variables Java handles?

  61. What are the relationships between classes?

  62. What is the general form of a class?

  63. What is the use of new keyword?

  64. If ObjA1 is an object of class A created using new keyword, What does the statement A ObjA2=ObjA1; mean?

  65. What is a constructor?

  66. What is the difference between a constructor and a method?

  67. What is the use of this keyword?

  68. What are destructors?

  69. How is object destruction done in Java?

  70. What is Garbage collection?

  71. What is the use of finalize method?

  72. Compare Garbage collection and finalize method?

  73. How is it guaranteed that finalize methods are called?

  74. What is method overloading?

  75. What is a String in Java?

  76. What is the difference between a String in Java and String in C/C++?

  77. Name a few String methods.

  78. What is the difference between Concat method and + operator to join strings?

  79. What is String Buffer?

  80. How does String class differ from the String Buffer class?

  81. Name some methods available under String Buffer class.

  82. Output of some expressions using String methods.

  83. How will you initialize arrays?

  84. What is arraycopy method? Explain with syntax.

  85. What are the methods under Util.Arrays?

  86. Use the array sort method to sort the given array.

  87. Give the syntax for array fill operation.

  88. What is vector? How is it different from an array?

  89. What is the constraint for using vectors?

  90. What is wrapper class?

  91. What are the different access specifiers available in Java?

  92. What is the default access specifier in Java?

  93. What is a package in Java?

  94. Name some Java API Packages.

  95. Name some JavaDoc Comments.

  96. What is CommandLine Arguments.

  97. Explain OOP Principles.

  98. Explain the features of Java Language.

  99. Compare and Contrast Java with C.

  100. Compare and Contrast Java with C++.

  101. Explain Constructors with examples.

  102. Explain the methods available under String and String Buffer Class.

  103. Explain the Date Class methods with examples.

  104. Discuss in detail the access specifiers available in Java.

  105. Explain the different visibility controls and also compare with each of them.

  106. Explain the different methods in java.Util.Arrays class with example.

  107. Explain Packages in detail.

  108. Discuss the methods under Array Class.

  109. Discuss some of the classes available under Lang package.

  110. Illustrate with examples: static and final.

  111. Explain method overriding with example program.

  112. What is javaDoc? Explain the comments for classes, methods, fields and link.

  113. Application Programs in Java.

  114. Define Inheritance

  115. What are the types of inheritance?

  116. How is multiple inheritance achieved in java?

  117. What is the use of super keyword?

  118. What are object wrappers? Give example.

  119. What is Inheritance Hierarchy?

  120. Differentiate overloading and overriding.

  121. Define polymorphism.

  122. Differentiate static binding and dynamic binding.

  123. When will a class be declared as final?

  124. When will a method be declared final?

  125. What is an abstract class?

  126. What is the need for abstract classes?

  127. Explain about protected visibility control.

  128. What are the methods under "object" class / java.lang.Object.

  129. Explain toString method of object class.

  130. What is reflection?

  131. What are the uses of reflection in Java.

  132. How will you create an instance of Class.

  133. What are the methods under reflection used to analyze the capabilities of classes?

  134. How to create arrays dynamically using reflection package.

  135. Define an interface.

  136. What is the need for an interface?

  137. What are the properties of an interface?

  138. Differentiate Abstract classes and interface.

  139. What is object cloning?

  140. Differentiate cloning and copying.

  141. Differentiate shallow copy and deep copy in cloning.

  142. Does Inheritance removes any fields/or methods of super class?

  143. Mention the use of final keyword.

  144. What is nested class? Mention its types.

  145. What is inner class?

  146. What is the need for inner classes?

  147. What are the rules for inner class?

  148. What is local inner class and anonymous inner class? Give their advantages.

  149. Write the advantages and disadvantages of static nested class.

  150. Define proxies.

  151. Write the application of proxies.

  152. What are the properties of proxy classes?

  153. Explain the concept of inheritance and its types.

  154. Explain the concept of overriding with examples.

  155. What is dynamic binding? Explain with example.

  156. Explain the uses of reflection with examples.

  157. Define an interface. Explain with example.

  158. Explain the methods under “object” class and “class” class.

  159. What is object cloning? Explain deep copy and shallow copy with examples.

  160. Explain static nested class and inner class with examples.

  161. With an example explain proxies.

  162. Develop a message abstract class which contains playMessage abstract method. Write a different sub-classes like TextMessage, VoiceMessage and FaxMessage classes for to implementing the playMessage method.

  163. Develop a abstract Reservation class which has Reserve abstract method. Implement the sub-classes like ReserveTrain and ReserveBus classes and implement the same.

  164. Develop an Interest interface which contains simpleInterest and compInterest methods and static final field of Rate 25%. Write a class to implement those methods.

  165. Develop a Library interface which has drawbook(), returnbook() (with fine), checkstatus() and reservebook() methods. All the methods tagged with public.

  166. Develop an Employee class which implements the Comparable and Cloneable interfaces. Implement the sorting of persons (based on name in alphabetical). Also implement the shallow copy (for name and age) and deep copy (for DateOfJoining).

  167. Explain the different methods supported in Object class with example.

  168. Explain the methods supported in Class class.

  169. Explain the Methods supported in reflect package. Also write a program to implement the reflection of a particular class details like constructors, methods and fields with its modifiers.

  170. Develop a static Inner class called Pair which has MinMax method for finding min and max values from the array.

  171. What is proxy class? Develop a code for constructing a proxy objects to trace a binary search method with explanations.

  172. Draw the inheritance hierarchy for the frame and component classes in AWT and Swing.

  173. What are the advantages of using swing over awt?

  174. How do achieve special fonts for your text? Give example.

  175. Give the syntax of drawImage() and copyArea() methods.

  176. What is Adapter class?

  177. Draw the AWT event Hierarchy.

  178. What are the swing components?

  179. What are the methods under Action Interface.

  180. What are the methods under WindowListener Interface.

  181. What is the difference between Swing and AWT?

  182. Explain the classes under 2D shapes.

  183. Explain event handling with examples.

  184. Explain action event with an example.

  185. What are the swing components. Explain.

  186. Describe the AWT event hierarchy.

  187. What is generic programming?

  188. What are Checked and UnChecked Exception?

  189. What are checked exceptions?

  190. What are runtime exceptions?

  191. What is the difference between error and an exception?

  192. What classes of exceptions may be caught by a catch clause?.

  193. If I want an object of my class to be thrown as an exception object, what should I do?

  194. How to create custom exceptions?

  195. What are the different ways to handle exceptions?

  196. What is the purpose of the finally clause of a try-catch-finally statement?

  197. What is the basic difference between the 2 approaches to exception handling.

  198. Is it necessary that each try block must be followed by a catch block?

  199. How does Java handle integer overflows and underflows?

  200. Explain generic classes and methods.

  201. Explain exception hierarchy.

  202. What are the advantages of Generic Programming?

  203. Explain the different ways to handle exceptions.

  204. How Java handle overflows and underflows?

  205. Describe synchronization in respect to multithreading.

  206. Explain different way of using thread?

  207. What is synchronization and why is it important?

  208. When a thread is created and started, what is its initial state?

  209. What are synchronized methods and synchronized statements?

  210. What is daemon thread and which method is used to create the daemon thread?

  211. What method must be implemented by all threads?

  212. What kind of thread is the Garbage collector thread?

  213. What is a daemon thread?

  214. What is a thread?

  215. What is the algorithm used in Thread scheduling?

  216. What are the different level lockings using the synchronization keyword?

  217. What are the ways in which you can instantiate a thread?

  218. What are the states of a thread?

  219. What are the threads will start, when you start the java program?

  220. What are the different identifier states of a Thread?

  221. Why do threads block on I/O?

  222. What is synchronization and why is it important?

  223. Explain the different states of a thread.

  224. Explain thread synchronization with examples.

  225. Explain the algorithm used for thread scheduling.

  226. Describe multi threading.

  227. Explain Deadlocks.

  228. Explain JVM.

  229. Explain Bytecode.

  230. Explain the three principles of Java.

  231. What is class and instance of a class?

  232. What are objects? How to create objects?

  233. Explain the features of OOP.

  234. Explain how the concept of polymorphism is implemented in Java?

  235. Explain encapsulation in the object oriented programming.

  236. What is encapsulation? How does Java achieve encapsulation?

  237. How does Java incorporates the concept of polymorphism? Give one example.

  238. What do you understand by encapsulation in Java?

  239. Explain the steps involved in implementation of a Java program.

  240. Explain the use of JVM.

  241. What is Java Development Kit (JDK)?

  242. Explain the term polymorphism with an example.

  243. Explain the features of Java.

  1. Is the following statement true or false? If it is false then supply suitable example:

  2. “The data is lost when converted from higher data type to lower data type.”

  3. Can you make the keyword public to private in main() method? If yes, what will happen?

  4. Explain with an example data types boolean and byte in Java.

  5. Explain with an example data type byte in Java.

  6. What is type conversion in Java? Explain with an example.

  7. Write the difference between the operators = and = = in Java.

  8. What is type casting? Give an example to explain it.

  9. What are literals? State the boolean literals.

  10. List the different operators in Java.

  11. What are literals in Java? Mention their different types.

  12. What are different integer data types in Java?

  13. Explain any two logical operators in Java with example.

  14. What is meant by an assignment statement? For what purpose it is used?

  15. State the bitwise operators in Java. Explain any one.

  1. Write the difference between break and continue statements in Java.

  2. Explain switch statement in Java.

  3. Explain switch statement with example in Java.

  4. Explain the goto statement in Java.

  5. Explain while loop in Java.

  6. Explain any one loop statement in Java with an example.

  1. Explain how arrays are created in Java? How array elements are accessed?

  2. How do you declare an array in Java? Give an example.

  3. How do you declare a two dimensional array in Java? Give an example.

  4. Define an array. How do you declare and create array objects?

  1. Can you have two return statements in a method? Can you write any statement after return? Explain.

  2. Write difference between constructor and method.

  3. Can you have a method without return statement? Explain.

  4. Explain the use of the keyword static in Java.

  5. Explain overloading in Java.

  1. Explain the return statement in Java.

  2. State whether the following statement is true/false with justification “when a reference variable is assigned to another reference variable, another copy of object is created.”

  3. Explain the keyword new in Java.

  4. Explain the meaning of the keywords used in the declaration of main() method.

  5. What is an instance variable? How does one access an instance variable of a class?

  6. Explain different types of constructors in Java.

  7. What are constructors? How are they different from methods?

  8. Explain overloading methods with an example.

  9. Write a short note on this keyword.

  1. Explain the finalize method.

  2. What do you understand by an abstract class?

  3. What is method overriding and how does it differ from methos overloading in Java?

  4. When can a method in super class be prevented from being overridden by a method in subclass?

  5. Explain by an example.

  6. Explain in brief the overriding methods in Java.

  7. Explain the use of the keyword final in Java programming.

  8. Explain the use of finalize method.

  9. State the different access specifiers available in Java.

  10. What is method overriding and how does one prevent a method from being overridden?

  11. State any two differences between method overloading and method overriding.

  12. What do you understand by inheritance in Java?

  13. How does a subclass constructor call a super class constructor?

  14. Write a note on finalizer method.

  15. Explain the keyword super in Java.

  16. What is a class and a subclass? Give examples.

  17. What is inheritance? Is multiple inheritance supported by Java?

  18. What is data abstraction?

  19. Explain the terms subclass and super class.

  20. What are different access specifiers in Java?

  21. What do you mean by final variable and final method?

  22. Explain an abstract class.

  1. Explain the term package.

  2. What is the major difference between an interface and a class?

  3. Explain how to use a particular package in a Java program. Give example.

  4. What is an interface? How is it implemented?

  5. What do you mean by a package in Java?

  1. Write a method to fill a rectangle with red color.

  2. What is an applet? How do applets differ from an application programs?

  3. Explain life cycle of an applet.

  4. Write a method in Java applet to display a circle.

  5. How do we pass parameters to an applet? Give one example.

  6. What does your method do when start() (life cycle of an applet) is called?

  7. Explain destroy() method, a stage in the life cycle of an applet.

  8. Write a method to display a message “Computer Programming” at position (50, 20) inside a square.

  9. Explain drawRect () method in Graphics class with suitable example.

  10. How getParameter () method is used in applet?

  11. Explain Font class and Color class.

  12. Explain the steps involved to execute and run an applet.

  13. What is AWT? What are the various components in AWT?

COMPILER DESIGN

QUESTION BANK

1.Explain why it is possible to design an independent Lexical Analyzer?

2.What are the drawbacks of SLR(1) Parser? 3.What are the various data structures used to create a symbol table? 4.What do you mean by porting of a compiler? 5.Why LR parsing is prefer over other parsers?(Advantages of LR Parser) 6.What is dead code elimination? 7.What is Reduce-Reduce and Shift-Reduce conflict in LR parser?

8.What are the goals of error handler in a parser? 9.What are the error recovery actions in a Lexical Analyzer? 10.What is the basic block in code segment? What is Back patching?

11.What is S-attributed grammar and L-attributed grammar in semantic analysis?

12.What do you mean by postfix translations? 13.Differentiate between NFA and DFA. 14.Define CFG. Explain ambiguity in CFG.

15.Explain about compile time and run time errors. 16.Describe the structure of LL parser and LR parser.

17.Distinguish between syntax and semantics of a programming language. 18.What are the main function of the different stages of a compiler? 19.What is Syntax Directed Translation Scheme(SDTS)? 20.What are the different forms of intermediate code used in compilation process? 21.Describe the use of Flow Graph in Compiler writing.

22.Why do most compilers contain symbol table?

23. Define Cross Compiler. Explain Bootstrapping. 24.Why common approach is being used to design the lexical analyzer for compilers? 25.Explain the Front end and Back end of a compiler. 26.What is LL(1) and SLR(1)Grammar?

27.What is LEX,YACC,FLEX and BISON?

28.What is a semantic error? Explain with an example. 29.Name the methods of code optimization. 30.What are the various problems in code generations? 31.What are the various data structures used in LR parser design? 32.Explain Top-down and Bottom-up parsing.

33.Define Token & Lexeme.Construct NFA for the RE:(a|b)*abb,and convert it to DFA

34.Draw the state transition diagram for BEGIN,IF,THEN,ELSE,END

35Explain SDTS ,SDD , L-attributed& S-attributed grammar.

36 Explain in detail about symbol table.

37.Explain in detail about code optimization. 38.Explain the symbol table of a compiler for a block structured Language. 39.Explain in details about intermediate code generation.

40.Write Quadruples ,Triples & Indirect Triples for the following expression:(i)X[I]:=Y,X:=Y[I] (ii) -(a+b)*(c+d)-(a+b+c)

41.Describe Run Time Storage Allocation. 42.Discuss the construction of ACTION and GOTO table for SLR,CLR and LALR Parser. 43.What is an Activation record? Explain its different components.

44.Explain the various issues in the design of code generator.

45.What is DAG? Explain its algorithm. Construct the DAG for the following statements: T1:=4*I,T2:=addr(A)-4,T3:=T2[T1],T4:=4*I,T5:=addr(B)-4, T6:=T5[T4],T7:=T3*T6,T8:=PROD+T7,PROD=T8,T9:=I+1,I:=T9, if I<=20 goto (1)

46.Explain FIRST and FOLLOW algorithm. 47.Costruct the SLR Parse table for the following grammar: E->(L)|a, L->L,E|E Show the parsing action for the string ((a),a,(a,a))

48.Construct the Predictive parse table (LL parse table) for the following grammar: S->aBDh,B->cC, C->bc|€ , D->EF ,E->g|€ ,F->f|€ 49.For the following grammar :E->E*E,E->E+E,E->(E),E->id show the various shift- reduce parsing action with respect to the input string :id+id*id 50.Construct the CLR table for the grammar: S->AaAb, A->BbBa, A->€, B->€ 51.Construct the LALR table for the grammar:S->Aa|bAc|dc|bda , A->d 52.What are the necessity of optimization in compilation?Discuss the factors influencing optimization. 53.Define operator precedence relation and operator precedence grammar. Write down the steps for operator-precedence parser. Construct the mapped table for string ” *id=id” and show its parsing action. 54.Explain the elimination of Left factoring and Left recursion with example. 55.Explain the goals of error handler. Explain Lexical phase errors and show how to eliminate such errors. 565.Generate Three address code for the following code segment: main() { int a=1; int b[10]; while(a<=10) b[a]=2*a; } and also specify tokens and lexemes for this segment. 57.What is annotated parse tree? Construct such tree for the following: (4+3)*(5+7) 58.Find out FIRST and FOLLOW for the following grammar: S->aAB|Ba|€ , A->aAb|€ , B->Bb|c

  1. 58. What is Compiler? Design the Analysis and Synthesis Model of Compiler.

  2. 59. Write down the five properties of compiler.

  3. 60. What is translator? Write down the steps to execute a program.

  4. 61. Discuss all the phases of compiler with a with a diagram.

  5. 62. Write a short note on:

YACC

Pass

Bootstrapping d.

LEX Compiler

Tokens, Patterns and Lexemes

  1. 63. Write the steps to convert Non-Deterministic Finite Automata (NDFA) into Deterministic Finite Automata (DFA).

  2. 64. What is Regular Expression? Write the regular expression for:

a. R=R1+R2 (Union operation)

b. R=R1.R2 (concatenation Operation)

c. R=R1* (Kleen Clouser)

d. R=R+ (Positive Clouser)

e. Write a regular expression for a language containing strings which end with “abb” over

Ʃ= {a,b}.

f. Construct a regular expression for the language containing all strings having any

number of a’s and b’s except the null string.

  1. 65. Construct Deterministic Finite Automata to accept the regular expression : (0+1)* (00+11) (0+1)*

  1. 66. Derivation and Parse Tree:

Let G be a Context Free Grammar for which the production Rules are given below: S -> aB|bA

A -> a|aS|bAA B -> b|bS|aBB

Drive the string aaabbabbba using the above grammar (using Left Most Derivation and Right most

Derivation).

  1. 67. Explain the parsing techniques with a hierarchical diagram.

  2. 68. What are the problems associated with Top Down Parsing?

  3. 69. Write the production rules to eliminate the left recursion and left factoring problems.

    1. 70. Consider the following Grammar: A-> ABd|Aa|a

B-> Be|b

Remove left recursion.

  1. 71. Do left factoring in the following grammar: A-> aAB|aA|a

B-> bB|b

  1. 72. Write a short note on:

a. Ambiguity (with example)

b. Recursive Descent Parser

c. Predictive LL(1) parser (working)

d. Handle pruning

e. Operator Precedence Parser

  1. 73. . Write Rules to construct FIRST Function and FOLLOW Function.

    1. 74. Consider Grammar: E-> E+T|T

T-> T*F|F F-> (E)|id


Write the algorithm to create Predictive parsing table with the scanning of input string.

  1. 75. Show the following Grammar: S-> AaAb|BbBa

A-> €

B-> €

Is LL(1) and parse the input string “ba”

  1. 76. Consider the grammar: E-> E+E

E-> E*E

E->id

Perform shift reduce parsing of the input string “id1+id2+id3”.

  1. 77. Write the properties of LR parser with its structure. Also explain the techniques of LR parser.

  2. 78. Write a short note on:

a. Augmented grammar b. Kernel items

c. Rules of closure operation and goto operation d. Rules to construct the LR(0) items

  1. 79. Consider the following grammar: S-> Aa|bAc|Bc|bBa

A-> d

B-> d

Compute closure and goto.

  1. 80. Write the rules to construct the SLR parsing table.

    1. 81. Consider the following grammar: E-> E+T|T

T-> TF|F

F-> F*|a|b

Construct the SLR parsing table and also parse the input “a*b+a”

  1. 82. Write the rules to construct the LR(1) items.

    1. 83. What is LALR parser? Construct the set of LR(1) items for this grammar: S-> CC


C-> aC C->d

  1. 84. Show the following grammar

S->Aa|bAc|Bc|bBa

A->d

B->d

Is LR(1) but not LALR(1).

  1. 85. Write the comparison among SLR Parser, LALR parser and Canonical LR Parser.

  2. What is syntax directed translation (SDD)?

  3. Write short note on:

a. Synthesized attributes b. Inherited attributes

c. Dependency graph

d. Evaluation order

e. Directed Acyclic Graph (DAG)

  1. Draw the syntax tree and DAG for the following expression: (a*b)+(c-d)*(a*b)+b

  2. Differentiate between synthesized translation and inherited translation.

  3. What is intermediate code and write the two benefits of intermediate code generation.

  4. Write the short note on:

a. Abstract syntax tree

b. Polish notation

c. Three address code

d. Backpatching

  1. Construct syntax tree and postfix notation for the following expression:

(a+(b*c)^d-e/(f+g)

  1. Write quadruples, triples and indirect triples for the expression:

-(a*b)+(c+d)-(a+b+c+d)

  1. Write the three address statement with example for:

a. Assignment

b. Unconditional jump (goto)

c. Array statement (2D and 3D)

d. Boolean expression

e. If-then-else statement

f. While, do-while statement

g. Switch case statement

  1. Write the definition of symbol table and procedure to store the names in symbol table.

  2. What are the data structures used in symbol table?

  3. What are the limitations of stack allocation?

  4. Write two important points about heap management.

    1. Write the comparison among Static allocation, Stack allocation and Heap Allocation with their merits and limitations.

    2. What is activation record? Write the various fields of Activation Record.

    3. What are the functions of error handler?

    4. Write a short note on Error Detection and Recovery.

    5. Classify the errors and discuss the errors in each phase of Compiler.

    6. What are the properties of code generation phase? Also explain the Design Issues of this phase.

    7. What are basic blocks? Write the algorithm for partitioning into Blocks.

    8. Write a short note on:

a. Flow graph (with example)

b. Dominators

c. Natural loops

d. Inner loops

e. Reducible flow graphs

  1. Consider the following program code: Prod=0;

I=1; Do{ Prod=prod+a[i]*b[i]; I=i+1;

}while (i<=10);

  1. Partition in into blocks

  2. Construct the flow graph

  3. What is code optimization? Explain machine dependent and independent code optimization.

  4. What is common sub-expression and how to eliminate it? Explain with example.

  5. Write a short note with example to optimize the code:

a. Dead code elimination

b. Variable elimination

c. Code motion

d. Reduction in strength

111. What is control and data flow analysis? Explain with example.

111.Define a compiler?

112.Describe the Analysis Synthesis Model of compilation.

113.Define a symbol table.

114.What are the functions of preprocessors?

115.Define Assembly Code.

116.Define tokens, Patterns and lexemes.

117.What are the possible error recovery actions in lexical Analyzer?

118.What are the three general approaches to the implementation of a Lexical Analyzer?

119.Define a Sentinel.

120.Describe briefly rational preprocessors with an example.

121.What are the reasons for separating the analysis phase of compiling into Lexical analysis and parsing?

122.What is the function of a loader?

123.Give the diagrammatic representation of a language processing system.

124. Explain briefly the producer consumer pair of a lexical analyzer and parser.

125.Mention the issues in a lexical analyzer.

126.Mention some of the cousins of the compiler.

127.What are rational preprocessors?

128.Explain in detail about the role of Lexical analyzer with the possible error recovery actions.

129.(a)Describe the following software tools i. Structure Editors

ii. Pretty printers

iii. Interpreters

(b)Write in detail about the cousins of the compiler.

130. Describe in detail about input buffering. What are the tools used for constructing a compiler?

131.(a)Explain the functions of the Lexical Analyzer with its implementation.(10) (b)Elaborate specification of tokens.

132. (a)What is a compiler? Explain the various phases of compiler in detail, with a neat sketch.

133.(b) Elaborate on grouping of phases in a compiler.(6)

134.(a) Explain the various phases of a compiler in detail. Also write down the output for the following expression after each phase a: =b*cd. (8)

135.(b) What are the phases of the compiler? Explain the phases in detail. Write down the output of each phase for the expression a: = b +c * 50. (8)

136.Draw a NFA for a*|b*.

137.What do you mean by Handle Pruning?

138.Define LR (0) items.

139.What do you mean by viable prefixes?

140.Define handle.

141.What are the algebraic properties of regular expressions?

142.What is finite automata?

143.What are the goals of error handler in a parser?

144. What is an ambiguous grammar? Give an example.

145..What is phrase level error recovery?

146.What are the disadvantages of operator precedence parsing?

147.What is a predictive parser?

148.Eliminate left recursion from the following grammar A->Ac/Aad/bd/c.

149.What is LL (1) grammar? Give the properties of LL (1) grammar.

150.Give the algorithm for Left Factoring a Grammar.

151.What is Left Recursion? Give an example for eliminating the same.

152.What is FIRST and FOLLOW? Explain in detail with an example. Write down the necessary algorithm.

153.Construct Predictive Parsing table for the following grammar:

S > (L)/ a

S->(L)/a

L> L, S/S

and check whether the following sentences belong to that grammar or not.

(i) (a,a)

(ii) (a, (a , a))

(iii) (a,((a,a),(a,a)))

154.(a) Construct the predictive parser for the following grammar: S > (L)|a L > L,S|S.

(b) Construct the behaviour of the parser on sentence (a, a) using the grammar: S > (L)|a L > L,S|S.

155.4. (a) Check whether the following grammar is SLR (1) or not. Explain your answer with reasons. S> L=R S>R L>*R L>id R>L

(b) For the grammar given below, calculate the operator precedence relation and the precedence functions. E>E+E|E –E|E*E|E/E|E^E|(E)| E|id

156.Check whether the following grammar is a LL(1) grammar

S > iEtS | iEtSeS | a E> b

Also define the FIRST and FOLLOW procedures.

157.(a) Consider the grammar given below. E>E+T E>T T>T*F T>F F>(E)

F>id. Construct an LR Parsing table for the above grammar. Give the moves of LR

parser on id*id+id.

(b) What is a shiftreduce parser? Explain in detail the conflicts that may occur during shiftreduce parsing. (4)

158.How would you represent the following equation using the DAG, a: =b*c + b*c. What is the purpose of DAG?

159. What is the intermediate code representation for the expression a or b and not c ?

160.How would you map names to Values?

161.What are the various methods of implementing three address statements?

162.Suggest a Suitable approach for completing hash function.

163.What are the methods of representing a syntax tree?

164.Give the Syntax directed definition of if else statement.

165.What is back patching?

166.What are the applications of DAG?

167.Define marker non terminals with an example.

168.Why are quadruples preferred over triples in an optimizing Complier?

169.Give the triple representation of a ternary operation x:= y[i]

170.Give the Semantic rules for the production S _ while E do S1.

171.Let A be a 10x20 array with low1=low2=1. Therefore n1=10 and n2=20.

Take w to be 4. Give the annotated parse tree for the assignment x:=A[y,z]

172.What is short circuit or jumping code?

173.How would you generate the intermediate code for the flow of control statements?Explain with examples.

174.(a)What are the various ways of calling procedures? Explain in detail.

(b)What is a three address code? Mention its types. How would you implement the three address statements? Explain with examples.

175. How would you generate intermediate code for the flow of control statements? Explain with examples.

176.(a)Describe the method of generating syntax directed definition for

Control statements.

(b)Give the semantic rules for declarations in a procedure.

177.5. (a) How Back patching can be used the generate code for Boolean expressions and flow of control statements.

(b)Explain how the types and relative addresses of declared names are computed and how scope information is dealt with.

178.6. (a) Describe in detail the syntaxdirected translation of case statements.

(b) Explain in detail the translation of assignment statements.

179.How would you calculate the cost of an instruction?

180.What is an activation record for a procedure?

181.What is a Basic Block?

182.What are the steps involved in partitioning a Sequence of three address statements into basic blocks?

183.What are the limitations of static allocation?

184.What is dead code elimination?

185.Give the primary structure preserving transformations on Basic Blocks.

186.Draw the diagram of the general activation record and give the purpose of any two fields.

187.What is stack allocation?

188.What are dags and how are they useful in implementing transformations on basic blocks?

189.What is peephole optimization?

190.Mention the transformations that are characteristic of peephole optimizations.

191.What are machine idioms?

192.Give the applications of dags.

193.1What are register descriptors?

194.Briefly describe address descriptors.

195.(a)Explain the issues in design of code generator.

(b)Explain peephole optimization.

196.(a)Discuss run time storage management of a code generator. (b)Explain DAG representation of the basic blocks with an example.

197.(a)Explain the simple code generator with a suitable example. (b)Describe about the stack allocation in memory management.

198.(a) What are the different storage allocation strategies?

(b)What are steps needed to compute the next use information?

199. (a) Write detailed notes on Basic blocks and flow graphs.

(b)How would you construct a DAG for a Basic block? Explain with an example.

200.What are called optimizations and what is an optimization compiler?

201.Mention the criteria for code improving transformations.

202.Mention the function preserving, code improving transformations.

203.What is code motion? Give an example.

204.What is constant folding?

205.What are induction variables? What is induction variable elimination?

206. What is a cross compiler? Give an example.

207.What are the properties of optimizing compilers?

208.Mention the different storage allocation strategies.

209.Mention the limitations of static allocation.

210.What are calling sequences and give brief notes on its types.

211.When does a dangling reference occur? Give its impact on programs.

212.Give the situations in which stack allocation can not be used.

213.Mention the different types of parameter passing.

214.What are the two approaches of implementing Dynamic Scope? Give the difference between the two.

215.(a) Explain the principle sources of optimization in detail.

216. (b)What are the various ways of calling procedures?

217.2 (a) Discuss about the following:

i). Copy Propagation

ii) Deadcode Elimination and iii)Code motion

(b)Describe in detail about the stack allocation in memory management.

(a) Write about Data flow analysis of structural programs.

(b)Describe the various storage allocation strategies

218. (a) Describe in detail the source language issues.

(b) Explain in detail access to non local names.

219.(a) Elaborate storage organization.

(b)Write detailed notes on parameter passing.

220.(a) Explain optimization of basic blocks.

(b) Explain the various approaches to compiler development.

Sub:- Advance Lab.-I


Questions

  1. WAP to display the addition, subtraction, multiplication and division of two complex numbers.

2 WAP to print the Fibonacci series upto n terms.

3 WAP for the multiplication of two 4X4 matrix.

4 WAP for the implementation of multiple inheritance using interface mechanism.

5 Develop a java Swing program to design a calculator.

6 WAP to demonstrate multithreading mechanism.

7 Write a set of two JAVA programs for communicating between them using socket & datagram programming.

8 Write a JDBC Program to insert data into Student DATA BASE and retrieve info based on particular queries(For example update, delete, search etc…).

9 Write a set of JAVA programs to implement Remote method Invocation.

10 Write a JAVA Servlet Program to implement and demonstrate get() and Post methods(Using HTTP Servlet Class).

11 Write a JAVA JSP Program to implement verification of a particular user login and display a Welcome page.

12 Write a JSP program to read data from a DATABASE.

13 Using JSP develop a project to implement online examination system.

14 Develop a program using Applet to design a house.

15 WAP to handle multiple exception in Java.

16 WAP to find the area of rectangle, triangle and circle using user defined package.

17 Develop a project to implement online library management system.