Saturday, October 29, 2011

Java Interview Questions Part-8(AWT,Event Handling)





Q1.       When we invoke repaint() for a java.awt.Component object, the AWT invokes the method:

A.    update()
B.     draw()
C.    show()
D.    paint()

Q2.       What does the following line of code do?

TextField text = new TextField(10);

A.    Creates text object that can hold 10 rows of text.
B.     Creates the object text and initializes it with the value 10.
C.    Creates text object that can hold 10 columns of text.
D.    The code is illegal.

Q3.       Which of the following applet tags is legal to embed an applet class named Test into a Web page?

A.    < applet class = Test width = 200 height = 100>
B.     < applet> code = Test.class width = 200 height = 100>
C.    < applet code = Test.class width = 200 height = 100>
D.    < applet code = Test.class width = 200 height = 100
E.     < applet param = Test.class width = 200 height = 100>

Q4.       Which of the following methods can be used to draw the outline of a square within a java.awt.Component object?

(A) fillRect()       (B) drawLine()               (C) drawRect()               (D) drawString()         (E) drawPolygon()

A.    (A), (B), (C) & (E)
B.     (A), (B) & (C)
C.    (C), (D) & (E)
D.    (B), (C) & (E)
E.     (B) & (C)

Q5.       Which of the following methods can be used to change the size of a java.awt.Component object?

(A)  dimension() (B)  setSize()                 (C)  area()                     (D)  size()               (E)  resize()

A.    (A), (B), (C) & (E)
B.    (B) & (E)
C.    (A), (B) & (E)
D.    (B), (D) & (E)
E.     (D) & (E)

Q6.       Which of the following methods can be used to remove a java.awt.Component object from the display?

A.    delete()                   B.   remove()                 C.   disappear()                D.   hide()             E.   move()

Q7.       The setBackground() method is part of the following class in java.awt package:

A.     Graphics                 B.   Component                        C.   Applet                       D.   Container         E.   Object

Q8.       Which one 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 {
E.     class MyApplet implements Applet {

Q9.       Which is the method that starts the applet?

A.    main()                     B.   destroy()                 C.  init()                       D.   repaint()

Q10.     What is the difference between a TextArea and a TextField?

A.    A TextArea can handle multiple lines of text
B.     A textarea can be used for output
C.    TextArea is not a class
D.    TextAreas are used for displaying graphics

Q11.     What tags are mandatory when creating HTML to display an applet?

A.     name, height, width
B.      code, name
C.     codebase, height, width
D.     code, height, width

Q12.     What are the Applet’s life cycle methods?

A.   init(), start() and destroy()
B.   init(), start() and paint()
C.   init(), start(), paint(), stop() and destroy()
D.   init(), start() and stop()

Q13.     All Applets must import java.applet and java.awt.

A.    True                       B.   False

Q14.     What are the interfaces to deal with Applet applications?

A.   AppletContext, AppletConfig
B.   AppletContext, AppletStub, AudioClip
C.   AppletConfig, AppletStub, AudioClip
D.   AppletConfit, AppletStub, VideoClip

Q15.     Which of the following objects are input to the paint() method?

A.     Canvas                   B.   Graphics                C.   Paint                       D.   Image

Q16.     Which of the following methods set the frame surface color to pink?

A.    setBackground(Color.pink);                      C.   setColor(PINK);
B.     Background(pink);                            D.   None of the above

Q17.     How to create TextArea with 80 character-width wide and 10 character-height tall?

A.    new TextArea(80, 10)                       B.   new TextArea(10, 80)

Q18.     What is the immediate super class of Applet class?

A.    Object                     B.  Window                    C.   Panel                     D.   Component

Q19.     Which Component method is used to access a component's immediate Container?

A.    getVisible()              B.   getImmediate()        C.   getParent()                       D.  getContainer()

Q20.     Which of the following creates a List with 3 visible items and multiple selection disabled?

A.    new List(3, false)  B.   new List(true, 3)       C.   new List(3, True)     D.   new List(false,3)

Q21.     Window, Panel and ScrollPane are the subclasses of

A.    Container class     B.  Component class       C.   Frame class             D.  None of the above

Q22.     Which of the following components allow multiple selections?

A.     Non-exclusive Checkboxes                       B.  Radio buttons            C.   Choice                     D.   Text Boxes

Q23.     Which layout is used as their default layout by Window, Frame and Dialog classes?

A.     CardLayout             B.   BorderLayout        C.   FlowLayout              D.   GridLayout

Q24.       Which of the following statement(s) are true?

A.   The default layout manager for an Applet is FlowLayout
B.   The default layout manager for an application is FlowLayout
C.   A layout manager must be assigned to an Applet before the setSize method is called
D.   The FlowLayout manager attempts to honor the preferred size of any components

Q25.     What class is the top of the AWT event hierarchy?

A.   java.awt.AWTEvent
B.   java.awt.Event
C.   java.util.eventObject
D.   javax.swing.Object

Q26.       What is the result of executing the following Java class:

import java.awt.*;

public class FrameTest extends Frame {
            public FrameTest() {
                        add (new Button("First"));
                        add (new Button("Second"));
                        add (new Button("Third"));
                        pack();
                        setVisible(true);
            }
                       
            public static void main(String args []) {
                        new FrameTest();
            }
}

Select from the following options:

A.  Only the "third" button is displayed.
B.  A runtime exception is generated (no layout manager specified).
C.  Only the "first" button is displayed.
D.  Only the "second" button is displayed.

Q27.     If a frame uses a Grid layout manager and does not contain any panels, then all the components within the frame are the same width and height.

A.  True                                   B.   False

Q28.     An application has a frame that uses a Border layout manager. Why is it probably not a good idea to put a vertical scroll bar at North in the frame?

A.  The scroll bar’s height would be its preferred height, which is not likely to be enough.
B.  The scroll bar’s width would be the entire width of the frame, which would be much wider than
     necessary.
C.  Both a and b.
D.  Neither a nor b. There is no problem with the layout as described.

Q29.       How do you indicate where a component will be positioned using FlowLayout?

A.   North, South, East, West
B.   Assign a row/column grid reference
C.   Pass a X/Y percentage parameter to the add method
D.   Do nothing, the FlowLayout will position the component

Q30.     Which of the following options are correct regarding the organization of layouts (Select Multiple)

            A.   FlowLayout           :           The elements of a FlowLayout are organized in a top to bottom,      left to right
Fashion.
B.   BorderLayout:       The elements of a BorderLayout are organized at the borders (North, South, East and West) and the center of a container.
C.   CardLayout             :         The elements of a CardLayout are stacked, one on top of the other, like a deck of
cards.
D.   GridBagLayout :        The elements of a GridLayout are of equal size and are laid out using the square
of a grid

6 comments:

for IT the said...

Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai

Naviya Nair said...

I have read your blog its very attractive and impressive. I like it your blog.

Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai

jazz said...

Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your..
Vmware Training in Chennai

jazz said...

Finding the time and actual effort to create a superb article like this is great thing. I’ll learn many new stuff right here! Good luck for the next post buddy..
CCNA Training in Chennai

john brito said...

This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.
rpa training in chennai
rpa training in bangalore
rpa course in bangalore
best rpa training in bangalore
rpa online training

johnsy sai said...

Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
excel advanced excel training in bangalore
Devops Training in Chennai

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Vamshi krishnam raju | Bloggerized by Vamshi krishnam raju - Vamshi krishnam raju | Vamshi krishnam raju