K K Wagh Polytechnic, Nashik – 3
Question Bank
: Java Programming (9113)
Class
: TYIF (IF/V/C)
Chapter No. 05
Applets and Graphics Programming
Review Questions from previous MSBTE question papers: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20.
Explain the life cycle of Applet in detail. Give the hierarchy of Applet class. Describe the methods used in applet skeleton. Give differences between start( ) and init( ) methods of Applet class. Differentiate between application and an applet. Explain the syntax of standard HTML applet tag. State the differences between stop( ) and destroy( ) methods. Why it is necessary to declare the subclass of an Applet class as public? Explain the operations of paint( ) method. Why it is necessary? Why Java applet does not contain a main( ) method? How to pass parameters to the applet? Illustrate with example. Describe the methods getCodeBase( ) and getDocumentBase( ) with suitable example. Which are methods related to a Font and Color class? Explain. How to build applet into HTML file? How to connect two applet files to each other? Explain. Illustrate the use of update( ) and repaint( ) with example. Enlist applications of Applet. Explain various methods of Graphics to draw different shapes on the applet. How to draw a circle using drawOval( ) and drawArc( ) methods? Give and explain different syntax of creating polygons on applet.
Programming Exercises: 1. 2. 3. 4. 5. 6.
Create an applet with size 300 X 200 and display “Hello” on it at the center. Display the numbers from 1 to 10 reversely on the applet. Display a pentagon on the applet filled with green color. Create an applet to display the string “Applet Graphics Programming” with font “Courier New”, size: 15 points and BOLD + ITALIC. Display different concentric oval shapes on the applet at the center with different colors. Create an applet with blue background, yellow foreground and display string “Core Java Programming” with Arial font point size = 20.
By Mr. Kute T. B. for (TYIF) 2008-2009
-1-
K K Wagh Polytechnic, Nashik – 3
7. 8.
9. 10.
Accept a date using <param> tag and display along with the message, “My Birthday is: “. Accept the flower name as parameter and display it along with the message “It is a beautiful flower”. The HTML file should be placed in the directory called flower. The background color of this applet is light gray. The text displayed in Times new roman with 40 points. Input two strings from <param> tag concatenate them and display them in the status window. Create an applet with background color red and draw a circle at the middle of applet which if filled with blue color.
Objective questions: 1.
In order to cause the paint(Graphics) method to execute, which of the following is the most appropriate method to call: a) paint() b) repaint() c) paint(Graphics) d) update(Graphics) e) None – you should never cause paint(Graphics) to execute
2.
Consider the following tags and attributes of tags: 1 CODEBASE 2 ALT 3 NAME 4 CLASS 5 JAVAC 6 HORIZONTALSPACE 7 VERTICALSPACE 8 WIDTH 9 PARAM 10 JAR Which of the above can be used within the <APPLET> and tags? a) line 1, 2, 3 b) line 2, 5, 6, 7 c) line 3, 4, 5 d) line 8, 9, 10 e) line 8, 9
3.
Which of the following illustrates the correct way to pass a parameter into an applet: a)