Java Programming - Mid -2 - Question Bank UNIT-4 PART-A 1) What is the importance of synchronization in java? 2) What is a daemon thread? 3) Differentiate between sleep () and wait (). 4) How to read data in java file? Discuss. 5) What happen when PrintWriter methods receives a string type argument? PART-B 1. a) What is thread synchronization? Discuss with an example. b) Explain how communication between threads takes place with a programming example. 2. a) "Threads can be given priorities" - Support this statement with suitable example. b) Explain various thread states and properties in detail with a neat diagram 3. a) What is a stream? What is the difference between byte streams and character streams? How are they used to capture input from the user? b) Differentiate between FileReader and BufferReader. PROGRAMS: 1. Write a Java program that prints numbers from 1 to 10 line by line after every 5 seconds 2. Write a Java program to demonstrate multithreading operation. 3. Write a java program to implement producer consumer problem. 4. Write a java program to display all odd numbered lines of a text file. 5. Write a program to read user name from console and display some message for that user using streams. UNIT-5 PART-A a) What are the ways in which we can pass parameters to the applet? b) What is an event? What methods are available to handle events in java? c) What are the advantages of event driven programming? d) Compare nested class with inner class. Give examples for each. e) What is an adapter class? Give any two examples for it. PART-B 1. a) What is an applet? Explain its life cycle. b) Can applet class have a constructor? Justify your answer with proper explanation and example. 2. b) What is the roll of listener class in event handling? List-out abstract methods of some Listener classes. b) how parameters passed to applet from the web page? Give example. 3. a) Explain delegation event model in detail. b) Discuss about different event classes.
Programs: 1) Write an applet to display the mouse cursor position in that applet window. 2) Write an applet to display a smiley with a greeting message to the user. 3) Develop a java code that keeps the count of right clicks of mouse. . 4) Write a Java program to create a combo box which includes list of subjects. Copy the subjects in text field on click using applet. 5) Write Applets programs to accomplish the following tasks: i) Drawing polygons. ii) Drawing a line graph. UNIT-6 PART-A a) What is the role of layout manager in AWT or Swing? b) List out the differences between AWT and Swings. c) Differentiate between grid layout and gridbag layout managers. d) List the features of Menu component of AWT. PART-B 1. a) Discuss about java.awt.package. b) Explain about the components and containers of AWT. 2. a) Discuss in detail Menu bars and menus in Java with examples. b) Write notes on ScrollPane and Dialog box with examples. 3. a) Differentiate Choice Control and List control with examples. b) Explain about any two Layout Managers with example programs.
Programs: 1) Write a java program that makes a window with a scroll bar at the right side of the window. 2) Design a screen in Java which accepts text in text box. If the left mouse is clicked, convert the text to uppercase and if the right button is clicked, convert it to lower case. 3) Construct a frame with necessary components for bus reservation system of an agent. 4) Develop java program that have 11 text fields one submit button. When you press the button first 10 text field’s average has to be displayed in the 11th text field. 5) Develop java program that changes the color of a filled circle when you make a right click.