| ADVANCE JAVA (3360701) |
UNIT 1 & 2 JAVA APPLETS AND AWT
1) An applet is a Java class that extends the?
A. java.Applet class
B. java class
C. Applet class
D. java.applet.Applet class
Answer : D
2) Applets are designed to be embedded within an .
A. Javascript
B. Css
C. HTML
D. SQL
Answer : C
3) Which of the following is required to view an applet?
A. JCM
B. JDM
C. JVM
D. Java class
Answer : C
4) Which method is automatically called after the browser calls the init method?
A. start
B. stop
C. destroy
D. paint
Answer : A
5) Which method is only called when the browser shuts down normally?
A. start
B. stop
C. destroy
D. paint
Answer : C
6) paint() is an abstract method defined in AWT.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
Answer : A
7) method is defined in Graphics class, it is used to output a string in an applet.
A. display()
B. Print()
C. drawString()
D. transient()
Answer : C
8) What will be output for the following code? import java.awt.*;
import java.applet.*;
public class myapplet extends Applet { public void paint(Graphics g) {
g.drawString(“”A Simple Applet””, 20, 20);
} }
A. A Simple Applet
B. A Simple Applet 20 20
C. Compilation Error
D. Runtime Error
Answer : A
9) When the………………….. method of the Applet class is called, it displays the result of the Applet code on the screen.
A. paint( )
B. repaint( )
C. update( )
D. reupdate( )
Answer : A
10) Before we try to write applets, we must make sure that Java is installed properly and and also ensure that either the java …………….. or a java-enabled browser is available.
A. viewer( )
B. appletviewer( )
C. appletrunner( )
D. browserviewer( )
Answer : B
11) Arrange the steps involved in developing and testing the applet in correct order.
- creating an executable applet (.classfile)
- preparing <APPLET> tag
- creating HTML file
- building an applet code (.java file)
- testing the applet code
A. 1-i, 2-ii, 3-iii, 4-iv, 5-v
B. 1-ii, 2-iii, 3-iv, 4-v, 5-i
C. 1-iv, 2-i, 3-ii, 4-iii, 5-v
D. 1-iii, 2-iv, 3-v, 4-i, 5-ii
Answer : C
12) State whether the following statements about the Applets are True or False.
- Applets can communicate with other services on the network.
- Applets cannot run any program from the local computer.
A. True, False
B. False, True
C. True, True
D. False, False
Answer : B
13) Applet class is a subclass of the panel class, which is again a subclass of the ………………….. class.
A. object
B. component
C. awt
D. container
Answer : B
14) Applet class is a subclass of the panel class, which is again a subclass of the ………………….. class.
A. object
B. component
C. awt
D. container
Answer : D
15) The…………………….. method called the first time an applet is loaded into the memory of a computer.
A. init( )
B. start( )
C. stop( )
D. destroy( )
Answer : A
16) The ……………………… method is called every time the applet receives focus as a result of scrolling in the active window.
A. init( )
B. start( )
C. stop( )
D. destroy( )
Answer : B
17) Which of the following applet tags is legal to embed an applet class named Test into a webpage?
A. <applet class=Test width=200 height=100></applet>
B. <applet>code=Test.class width=200 height=100></applet>
C. <applet code=Test.class width=200 height=100></applet>
D. <appletparam=Test.class width=200 height=100></applet>
Answer : C
18) If you want to assign a value of 88 to the variable year, then which of the following lines can be used within an <applet> tag.
A. number = getParameter(88)
B. <number=99>
C. <param = radius value=88>
D. <param name=number value=88>
Answer : D
19) The……………………… class is an abstract class that represents the display area of the applet.
A. display
B. graphics
C. text
D. area
Answer : B
20) The graphics class provides methods to draw a number of graphical figure including i) Text ii) Lines iii) Images iv) Ellipse
A. i, ii and iii only
B. ii, iii and iv only
C. i, iii and iv only
D. All i, ii, iii and iv
Answer : D
21) The………………….. method is called to clear the screen and calls the paint( ) method.
A. update( )
B. paint( )
C. repaint( )
D. reupdate( )
Answer : D
22) The ………………….. method is automatically called the first time the applet is displayed on the screen and every time the applet receives focus.
A. update( )
B. paint( )
C. repaint( )
D. reupdate( )
Answer : B
23) The ………………. method is defined by the AWT which causes the AWT runtime system to execute a call to your applet’s update( ) method.
A. update( )
B. paint( )
C, repaint( )
D. reupdate( )
Answer : C
24) Text field can be created by which of the following methods.
- TextField( )
- TextFieldString( )
- TextField(int)
- TextField(string, int)
A. i, ii and iii only
B. ii, iii and iv only
C. i, ii and iv only
D. All i, ii, iii and iv
Answer : C
25) In java applet, we can display numerical values by first converting them into string and then using the method.
A. paint( )
B. drawstring( )
C. draw( )
D. convert( )
Answer : B
26) We can change the text to be displayed by an applet by supplying new text to be the applet through a…… tag.
A. <EDIT>
B. <CHANGE>
C. <REPLACE>
D. <PARAM>
Answer : D
27) Which of the following is/are the possible values for alignment attribute of Applet tag. i) Top ii) Left iii) Middle iv) Baseline
A. i, ii and iii only
B. ii, iii and iv only
C. i, iii and iv only
D. All i, ii, iii and iv
Answer : D
28) The……………………. attribute of applet tag specifies the amount of horizontal blank space the browser should leave surrounding the applet.
A. SPACE=pixels
B. HSPACE=piexls
C. HWIDTH=piexls
D. HBLANK=pixels
Answer : B
29) attribute of applet tag specify the width of the space on the HTML page that will reserved for the applet.
A. WIDTH=pixels
B. HSPACE=piexls
C. HWIDTH=piexls
D. HBLANK=pixels
Answer : A
30) The following example shows the creation of a
import java.applet.*;
import java.awt.*;
public class Main extends Applet
{ public void paint(Graphics g)
{ g.drawString(“Welcome in Java Applet.”,40,20); } }
A. Banner using Applet
B. Basic Applet
C. Display clock
D. None of the above
Answer : B
31) An applet can play an audio file represented by the AudioClip interface in the java, applet package Causes the audio clip to replay continually in which method?
A. public void play()
B. public void loop()
C. public void stop()
D. None of the above
Answer : B
32) Which are the common security restrictions in applets?
A. Applets can’t load libraries or define native methods
B. An applet can’t read every system property
C. Applets can play sounds
D. Both A & B
Answer : D
33) From the following statements which is a drawback for Applet?
A. It works at client side so less response time
B. Secured
C. It can be executed by browsers running under many platforms, including Linux, Windows, and Mac Os etc.
D. Plugin is required at client browser to execute applet
Answer : D
34) Applet works at client side so less response time.
A. True
B. False
Answer : A
35) The APPLET tag is used to start an applet from both an HTML document and from an applet viewer.
A. True
B. False
Answer : A
36) Applets cannot make network connection exception to the server host from which it originated.
A. True
B. False
Answer : A
37) What invokes immediately after the start() method and also any time the applet needs to repaint itself in the browser?
A. stop()
B. init()
C. paint()
D. destroy()
Answer : C
38) Which method is called only once during the run time of your applet?
A. stop()
B. paint()
C. init()
D. destroy()
Answer : C
39) When an applet is terminated which of the following sequence of methods calls take place?
A. stop(),paint(),destroy()
B. destroy(),stop(),paint()
C. destroy(),stop()
D. stop(),destroy()
Answer : D
40) Applet runs inside the browser and does not works at client side.
A. True
B. False
Answer : B
41) Which is a special type of program that is embedded in the webpage to generate the dynamic content?
A. Package
B. Applet
C. Browser
D. None of the above
Answer : B
42) What is used to run an Applet?
A. An html file
B. An AppletViewer tool(for testing purpose)
C. Both A & B
D. None of the above
Answer : C
43) Which is the correct order of lifecycle in an applet?
A. Applet is started,initialized,painted,destroyed,stopped
B. Applet is painted,started,stopped,initilaized,destroyed
C. Applet is initialized,started,painted,stopped,destroyed
D. None of the above
Answer : C
44) Java Plug-in software is not responsible to manage the lifecycle of an Applet.
A. True
B. False
Answer : B
45) Which method is used to suspend threads that don’t need to run when the applet is not visible?
A. destroy()
B. paint()
C. stop()
D. start()
Answer : C
46) All Applets must import java.applet and java.awt.
A. True
B. False
Answer : A
47) When an applet begins, in which sequence will the AWT call the methods?
A. init(),paint(),start()
B. Start(),paint(),init()
C. intit(),start(),paint()
D. paint(),start(),init()
Answer : C
48) Which applet java.awt.component class provides the life cycle method?
A. public void paint(Graphics g)
B. public void destroy()
C. public void stop()
D. public void init()
Answer : A
49) Which is invoked after the init() method or browser is maximized?
A. public void start()
B. public void paint(Graphics g)
C. Public void stop()
D. Public void init()
Answer : A
50) java.applet defines how many interfaces?
A. 2
B. 3
C. 4
D. 5
Answer : B
51) Which of these functions is called to display the output of an applet?
A. display()
B. paint()
C. displayApplet()
D. PrintApplet()
Answer: B
52) Which of these methods can be used to output a string in an applet?
A. display()
B. print()
C. drawString()
D. transient()
Answer: C
53) Which of these methods is a part of Abstract Window Toolkit (AWT) ?
A. display()
B. paint()
C. drawString()
D. transient()
Answer: B
54) What is the length of the application box made by the following
Java program?import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{ public void paint(Graphics g)
{ g.drawString(“A Simple Applet”, 20, 20);}}
A. 20
B. 50
C. 100
D. System dependent
Answer: A
55) What is the length of the application box made the following Java program?import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{ Graphic g; g.drawString(“A Simple Applet”, 20, 20); }
A. 20
B. Default value
C. Compilation Error
D. Runtime Error
Answer: C
56) To write applet application which class we need to extends?
A. Component
B. Applet
C. Applet
D. None of above
Answer: B
57) State true or false: Applet application have main method.
A. True
B. False
Answer: B
58) Which of the following is not part of java.awt.Component class?
A. init()
B. start()
C. paint()
D. All of Above
Answer: C
59) To write applet application which packages need to import?
A. import java.applet.Applet;
B. import java.awt.*;
C. Both A & B
D. None of above
Answer: C
60) Which attribute of applet tag compulsory to display applet?
A. Code
B. Width
C. Height
D. All of Above
Answer: D
61) Which attribute is required to give the name of the file containing your applet’s compiled .class file?
A. Code
B. codebase
C. alt
D. name
Answer: A
62) when an applet is terminated the following sequence of methods calls takes place?
A. stop(), paint(), destroy()
B. stop(), destroy()
C. destroy(), stop()
D. destroy(), stop(), paint()
Answer: B
63) State true or false: Applet executes at client side.
A. True
B. False
Answer: A
64) Which is common restriction in applet?
A. An applet cannot access anything on the system except browser’s services
B. Applets can’t load libraries or define native methods
C. Applets can play sounds
D. Both A & B
Answer: D
65) PARAM tag used for
A. To specify applet-specific arguments in an HTML page
B. To specify browser-specific arguments in an HTML page
C. To specify client-specific arguments in an HTML page
D. None of above
Answer: A
66) Which of the following is a valid declaration of an applet?
A. public class MyApplet extends java.applet.Applet {
B. public Applet MyApplet {
C. public class MyApplet extends applet implements Runnable {
D. abstract class MyApplet extends java.applet.Applet {
Answer: A
67) Which of the following is correct syntax to display 30*50 rectangle as output in applet?
A. g.drawRect(10,20,50,30);
B. g.drawRect(30,50,10,30);
C. g.drawRect(10,20,30,50);
D. g.drawRect(30,50,10,50);
Answer: C
68) Which of the following is correct syntax to display circle of redius 20 as output in applet?
A. g.drawCircle(10,20,20,20);
B. g.drawOval(10,20,20,20);
C. g.drawCircle(20,20,40,40);
D. g.drawOval(10,20,40,40);
Answer: D
69) drawLine, drawRect, drawString are available in which of the following class?
A. Paint
B. Graphics
C. Applet
D. Design
Answer: B
70) To display vertical line which of the following method is used?
A. drawStraightLine()
B. drawVerticalLine()
C. drawLine()
D. None of above
Answer: C
71) To add component in an applet which of following is used?
A. add()
B. put()
C. place()
D. None of above
Answer: A
72) What will be the output of getCodeBase( ) method?
A. Returns the URL of the HTML document that invokes the applet
B. Returns the URL associated with the invoking applet
C. Both A & B
D. None of above
Answer: B
73) What is fullform of AWT?
A. Application Window Toolkit
B. Abstract Web Toolkit
C. Abstract Writing Toolkit
D. Abstract Window Toolkit
Answer: D
74) Which method invoked by AWT when invoking repaint() method for component?
A. show()
B. draw()
C. paint()
D. update()
Answer: C
75) Program which executes applet is known as
A. JVM
B. Virtual machine
C. Applet engine
D. None of above
Answer: C
76) Which of following event generate when input received from keyboard?
A. KeyBoardEvent
B. KeyPressedEvent
C. KeyEvent
D. None of Above
Answer : C
77) Which of following event generate when checkbox is clicked?
A. CheckBoxEvent
B. ItemPressEvent
C. ItemEvent
D. ClickEvent
Answer : C
78) Which of following event generate when button is pressed?
A. Window Event
B. ActionEvent
C. PressEvent
D. ButtonEvent
Answer : B
80) Which package needs to import for headlining event?
A. Java.Applet
B. Java.awt.event
C. Java.event
D. None of Above
Answer : B
81) Which of following interface define a method itemStateChanged ()?
A. ActionListener
B. ItemListener
C. MouseListener
D. ComponentListener
Answer : B
82) AWT components are
A. heavyweight
B. lightweight
C. equal weight
D. None of Above
Answer : A
83) component provides to show various dialog such as error, user specific message, confirmation etc.
A. JDialogBox
B. JFileChooser
C. Jtable
D. JOptionPane
Answer : D
84) Which inbuilt dialog allows user to select file?
A. JFileInputChooser
B. JFileChooser
C. JFileSelector
D. JFileInputSelector
Answer : B
85) Which class is used to implement radiobutton using swing?
A. RadioButton
B. JCheckBox with CheckboxGroup
C. JRadioButton
D. None of Above
Answer : C
86) Which package needs to import to implement swing program?
A. javax.swing
B. java.swing
C. java.awt
D. None of Above
Answer : A
87) Using which component user can implement radio button in AWT?
A. Checkbox with CheckboxGroup
B. Only Checkbox
C. RadioButton
D. JRadioButton
Answer : A
88) Which class provides many methods for graphics programming?
A. java.awt.Graphics
B. java.Graphics
C. java.awt
D. None of Above
Answer : A
89) To make dropdown menu of choice which component is used in AWT?
A. List
B. Combo box
C. Checkbox
D. Choice
Answer : D
90) Which statement creates a Text Area with 10 rows and 20 columns?
A. TextArea text = new TextArea(10,20);
B. TextArea text = new TextArea(20,10);
C. TextArea text = new TextArea(200);
D. None of Above
Answer : A
91) Following four methods commonly used in?
- Public void add (Component c)
- public void setSize (int width, int height)
- public void setLayout (LayoutManager m)
- public void setVisible (boolean)
A. Component class
B. Graphics class
C. Both A & B
D. None of Above
Answer : A
92) The size of a frame on the screen is measured in.
A. Inches
B. Dots
C. Nits
D. Pixels
Answer : D
93) AWT components are
A. Platform dependent
B. Platform Independent
C. Both A & B
D. None of Above
Answer : A
94) Which of the following is used to execute applet application?
A. Browser
B. AppletViewer
C. Both A & B
D. None of above
Answer : C
95) Which of these methods can be used to know which key is pressed?
A. getModifier()
B. getActionKey
C. getActionEvent()
D. getKey()
Answer : A
96) JIT meaning.
A. Java In Time
B. Just In Time
C. Join In Time
D. None of the Above
Answer : B
97) What does the following line of code do? Textfield text = new Textfield(10);
A. Creates text object that can hold 10 columns of text.
B. Creates text object that can hold 10 rows of text.
C. Creates the object text and initializes it with the value 10.
D. The code is illegal.
Answer : A
98) Who Invented JAVA?
A. Netscape
B. Microsoft
C. Sun
D. None of Above.
Answer : C
99) To run a compiled Java program, the machine must have what loaded and running?
A. Java virtual machine
B. Java compiler
C. Java byte code
D. A Web browser
Answer : A
100) Which of these methods is defined in MouseMotionListener class?
A. mouseClicked()
B. mousePressed()
C. mouseReleased()
D. mouseDragged()
Answer : D
101) Which class is used for creating a single and multiple selection list in GUI ?
A. Choice
B. List
C. Select
D. Choice List()
Answer : B
102) Which of these methods will respond when you click any button by mouse?
A. mouseEntered()
B. mousePressed()
C. mouseClicked ()
D. All of the Above.
Answer : D
103) Executable applet is
A. java html
B. java file
C. class file
D. Applet file
Answer : C
104) By default frame is visible.
A. True
B. False
Answer : B
105) Which of these methods are used to register a mouse motion listener?
A. addMouse()
B. addMouseListener()
C. addMouseMotionListener()
D. eventMouseMotionListener()
Answer : C
106) The following
1) It is lightweight.
2) It supports pluggable look and feel.
3) It follows MVC (Model View Controller) architecture are the advantages of
A. AWT
B. Swing
C. Both A & B
D. None of the Above
Answer : B
107) Which Applet Required an Internet connection to Load Data in a webpage?
A. Local Applet
B. Remote Applet
C. Internet Applet
D. Hybrid Applet
Answer : B
108) Which controls that do not support any interaction with the user?
A. List
B. Checkbox
C. Choice
D. Label
Answer : D
109) Which of these methods are used to register a keyboard event listener ?
A. KeyListener()
B. addKistener()
C. addKeyListener()
D. eventKeyListener()
Answer : C
110) Which of these events will be notified if scroll bar is manipulated?
A. ActionEvent
B. AdjustmentEvent
C. WindowEvent
D. Component Event
Answer : B
111) In applet lifecycle when stop () is called?
A. When Browser is Minimized.
B. When Browser is closed.
C. When user leaves the Page
D. All of Above
Answer : D
112) Which method can set or change the text in a Label?
A. getText()
B. setText()
C. setEditable()
D. None of Above.
Answer : B
113) Identify which is not a component.
A. Label
B. Choice
C. Applet
D. Textarea
Answer : C
114) Mandatory Attributes of an Applet.
A. Name,code,codebase
B. Codebase, height,width
C. Height,code,codebase
D. Code,Height,width.
Answer : D
115) Which container only provide rectangular area.
A. Frame
B. Applet
C. Panel
D. Window
Answer : C
116) Which layout is widely used for arranging components in row and column.
A. Flowlayout ()
B. BorderLayout ()
C. GridLayout ()
D. Card Layout ()
Answer : C
117) Which of these interfaces handles the event when a component is added to a container.
A. ComponentListener
B. FocusListener
C. ContainerListener
D. InputListener
Answer : C
118) In Graphics class which method is used to draws a rectangle with the specified width and height?
A. public void drawRect(int x, int y, int width, int height)
B. public abstract void fillRect(int x, int y, int width, int height)
C. public abstract void drawRectangle(int x1, int y1, int x2, int y2)
D. public abstract void drawRect(int x, int y, int width, int height)
Answer : A
119) In which layout, only one component is visible at a time.
A. GridLayout ()
B. Flowlayout ()
C. BorderLayout ()
D. CardLayout ()
Answer : D
120) Which of these interfaces define a method actionPerformed()?
A. InputListener
B. ComponentListener
C. ActionListener
D. ContainerListener
Answer : C
121) Which class is used to create a Radio Button in java?
A. Checkbox ().
B. Radio()
C. CheckboxGroup()
D. None
Answer : C
122) Which container that doesn’t contain title bar and MenuBars but it can have other components like button, textfield etc?
A. Frame
B. Panel
C. Container
D. Window
Answer : B
123) Which of these methods is a part of AWT?
A. Drawstring
B. display()
C. print()
D. paint()
Answer : D
124) To set the Background in an Applet where to write this setbackground() in an Applet life-cycle.
A. paint()
B. start()
C. Init()
D. Main()
Answer : C
125) What is byte code?
A. Machine-specific code
B. Java code
C. Machine-independent code
D. None of the mentioned
Answer : C
126) How many methods keyListener have?
A. 5
B. 3
C. 7
D. 2
Answer : B
127) Identify ,which is not a container.
A. Panel
B. Window
C. Frame
D. Layout
Answer : D
128) Which method is Required to get parameters value in an applet?
A. <Param name=name value=value>
B. setParameter()
C. getParameter()
D.<applet><Param name=name value=value></applet>
Answer : C
129) Swing component are
A. HeavyWeight
B. LightWeight
Answer : B
130) Which container contains title bar, optional menu bar and minimize,maximize buttons.
A. Panel
B. Applet
C. Frame
D. Window
Answer : C
131) Swing has more powerful components like tables, lists, scroll panes, color chooser, tabbed pane etc.
A. True
B. False
Answer : A
132) Implement the Listener interface and overrides its methods is required to perform in event handling.
A. True
B. False
Answer : A
133) Which method is used to set the graphics current color to the specified color in the graphics class?
A. public abstract void setFont(Font font)
B. public abstract void setColor(Color c)
C. public abstract void drawString(String str, int x, int y)
D. None of the above
Answer : B
134) The Java Foundation Classes (JFC) is a set of GUI components which simplify the development of desktop applications.
A. True
B. False
Answer : A
135) Which object can be constructed to show any number of choices in the visible window?
A. Labels
B. Choice
C. List
D. Checkbox
Answer : C
136) Which is used to store data and partial results, as well as to perform dynamic linking, return values for methods, and dispatch exceptions?
A. Window
B. Panel
C. Frame
D. Container
Answer : C
137) Which class is used for this Processing Method processActionEvent( )?
A. Button,List,MenuItem
B. Button,Checkbox,Choice
C. Scrollbar,Component,Button
D. None of the above
Answer : A
138) Which is a component in AWT that can contain another components like buttons, textfields, labels etc.
A. Window
B. Container
C. Panel
D. Frame
Answer : B
139) How many types of controls does AWT support?
A. 7
B. 6
C. 5
D. 8
Answer : A
140) Which package provides many event classes and Listener interfaces for event handling?
A. java.awt
B. java.awt.Graphics
C. java.awt.event
D. None of the above
Answer : C