AWT and Swing - Java (MCQ) questions and answers

Dear Readers, Welcome to AWT and Swing multiple choice questions and answers with explanation. These objective type AWT and Swing questions are very important for campus placement test and job interviews. Specially developed for the Networking freshers and professionals, these model questions are asked in the online technical test and interview of many IT companies.

1)   Where are the following four methods commonly used?

1) public void add(Component c)
2) public void setSize(int width,int height)
3) public void setLayout(LayoutManager m)
4) public void setVisible(boolean)

- Published on 19 Oct 15

a. Graphics class
b. Component class
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Component class

Explanation:
No explanation is available for this question!


2)   Implement the Listener interface and overrides its methods is required to perform in event handling.

- Published on 19 Oct 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
No explanation is available for this question!


3)   Which is the container that doesn't contain title bar and MenuBars but it can have other components like button, textfield etc?
- Published on 19 Oct 15

a. Window
b. Frame
c. Panel
d. Container
Answer  Explanation 

ANSWER: Panel

Explanation:
No explanation is available for this question!


4)   These two ways are used to create a Frame

By creating the object of Frame class (association)
By extending Frame class (inheritance)

- Published on 19 Oct 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
No explanation is available for this question!


5)   Give the abbreviation of AWT?
- Published on 22 Jul 15

a. Applet Windowing Toolkit
b. Abstract Windowing Toolkit
c. Absolute Windowing Toolkit
d. None of the above
Answer  Explanation 

ANSWER: Abstract Windowing Toolkit

Explanation:
No explanation is available for this question!


6)   Which method is used to set the graphics current color to the specified color in the graphics class?
- Published on 22 Jul 15

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  Explanation 

ANSWER: public abstract void setColor(Color c)

Explanation:
No explanation is available for this question!


7)   The Java Foundation Classes (JFC) is a set of GUI components which simplify the development of desktop applications.
- Published on 22 Jul 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
No explanation is available for this question!


8)   In Graphics class which method is used to draws a rectangle with the specified width and height?
- Published on 22 Jul 15

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 drawLine(int x1, int y1, int x2, int y2)
d. public abstract void drawOval(int x, int y, int width, int height)
Answer  Explanation 

ANSWER: public void drawRect(int x, int y, int width, int height)

Explanation:
No explanation is available for this question!


9)   Which object can be constructed to show any number of choices in the visible window?
- Published on 22 Jul 15

a. Labels
b. Choice
c. List
d. Checkbox
Answer  Explanation 

ANSWER: List

Explanation:
No explanation is available for this question!


10)   Which is used to store data and partial results, as well as to perform dynamic linking, return values for methods, and dispatch exceptions?

- Published on 21 Jul 15

a. Window
b. Panel
c. Frame
d. Container
Answer  Explanation 

ANSWER: Frame

Explanation:
No explanation is available for this question!


1 2 3