Informatics Practices Study Material for Class XI C.B. S.E. Board Students


 Getting Started with Swing UI (User Interface) Components

Some Important Questions with Answers

1. Which window is used to design the form?
Ans: Design window
2. Which window contains the Swing Controls components?
Ans: Palette window
3. What is the most suitable component to accept multiline text?
Ans : Text Area
4. What will be the output of the following command?
Learning.concat("Java")
Ans : Error
5. What will be the output of the following command?
"Learning".concat("Java")
Ans: LearningJava
6. Name the different list type controls offered by Java Swing.
Ans: (i) jListBox
        (ii) jComboBox
7. Name any two commonly used method of ListBox.
Ans: getSelectedIndex() and getSelectedValue()

8. Write code to add an element (“New Course”) to a list (SubList) at the beginning of the list.
Ans: SubList.add(0,”New Course”);
9. Describe the three common controls. Also give some of their properties.
Ans:
(i) jButton text,icon
(ii) jLabel text,border
(iii) jTextField text,font
10. By default a combo box does not offer editing feature. How would you make a combo box editable.
Ans: By setting its editable property to false.
11. Write Name the component classes of Swing API for the following components-
(a) frame (b) button
Ans:(a)JFrame(b)JButton
12. What is the name of event listener interface for action events?
Ans: ActionPerformed
13. What does getpassword() on a password field return ?
Ans: a character array
14. What is event driven programming?
Ans: This programming style responds to the user events and is driven by the occurrence of user events.


15. What are containers? Give examples.
Ans: Containers are those controls inside them e.g., frame (JFrame), Panel (JPanel), label (JLabel) etc. are containers
16. which method of list is used to determine the value of selected item, if only one itm is selected.
Ans: getSelectedValue()
17. Which type of storage is provided by variables?
Ans: temporary
18. Explain the following terms:
a) IDE
b) Form
Ans: a) IDE : IDE is an acronym for Integrated Development Environment which is a work environment that integrates all tools necessary for Application Development and makes them available as part of one environment.
b) Forms: Forms are used to accept data (input) and submit data to an external agent for processing.
19. Explain the usage of the following methods :
a) setText()
b) toString()
c) concat()

a) setText() : It is used to change the display text of a component (label, text field or button) during run time.
b) toString() : It is used to convert an Integer value to String type.
c) concat() : The concat() method or the string concatenation symbol(+) may be used to add two strings together.
20. Differentiate between:
a) Text field and Text area components :
The Text Field allows the user to enter a single line of text only. But Text Area component allows to accept
multiline input from the user or display multiple lines of information.
b) Text field and Password field components:
The Text Field displays the obtained text in unencrypted form whereas password field displays the obtained
text in encrypted form. This component allows confidential input like passwords which are single line.
c) parseInt() and parseDouble() methods:
parseInt() is used to convert a string value to Integer type whereas parseDouble() is used to convert a
string value to type Double.
21. What is casting? When do we need it?
Ans: Casting is a conversion, which uses the cast operator to specify the type name in parenthesis and is
placed in front of the value to be converted.
For example: Result = (float) total / count ;
They are helpful in situations where we temporarily need to treat a value as another type.
22. Is Java case sensitive? What is meant by case sensitive?
Ans: Yes java is case sensitive. Case sensitive means upper case letters and lower case letters are treated
differently.
23. Is a string containing a single character same as a char?
Ans: No
24. What is the main difference between a combo box and a list box?
Ans: The List Box does not have a text field the user can use to edit the selected item, where as a Combo
Box is cross between a text field and a list.



2 comments: