Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
151 views6 pages

Assignment 1 12B PDF

GUI programming uses graphical user interfaces to allow users to interact with programs through visual elements like buttons and menus. Events like mouse clicks trigger event handlers, methods that respond to user interactions. The Java Swing library provides common GUI components to simplify development. When a user clicks a button, the default event handler name is the button name followed by "Action", so a button called "TestBtn" would have the handler "TestBtnAction". Lists allow multiple selectable items, with properties like "model" specifying the available options and "selectedIndex" indicating the chosen one. Containers hold and organize other controls as child components.

Uploaded by

Anjali Kotadia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
151 views6 pages

Assignment 1 12B PDF

GUI programming uses graphical user interfaces to allow users to interact with programs through visual elements like buttons and menus. Events like mouse clicks trigger event handlers, methods that respond to user interactions. The Java Swing library provides common GUI components to simplify development. When a user clicks a button, the default event handler name is the button name followed by "Action", so a button called "TestBtn" would have the handler "TestBtnAction". Lists allow multiple selectable items, with properties like "model" specifying the available options and "selectedIndex" indicating the chosen one. Containers hold and organize other controls as child components.

Uploaded by

Anjali Kotadia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1. What is GUI programming?

How Event-Driven methodology 


facilitates GUI programming? 
Answer: ​GUI: A graphical user interface (GUI) presents a 
pictorial interface to a program. GUI allows the user to spend less time 
trying to remember which keystroke sequences do what and spend 
more time using the program in a productive manner. 
An Event (occurrence of an activity) is generated when user does 
something like mouse click, dragging, pressing a key on the keyboard 
etc. 
 
 
2. How is swing related to GUI programming? 
Answer: ​The Java offers various Swing controls to facilitate 
development of GUI applications.  
 
3. What is an event? What is event handler? 
Answer: ​An Event (occurrence of an activity) is generated when 
user does something like mouse click, dragging, pressing a key on the 
keyboard etc. An Event Handler contains method/functions which is 
attached to a component and executed in response to an event. In 
Java, Listener Interface stores all Event-response-methods or 
Event-Handler methods. 
 
4. What is the default name of action event handler of a button 
namely TestBtn? 
Answer: ​jButton1 
 
 
5. What property would you set to assign access key to a button? 
Answer: ​Mnemonic property 
 
 
6. Which property would you set the setting the password 
character as ‘$’? 
Answer: ​echoChar property. 
 
7. Which method returns the password entered in a password 
field? 
Answer: ​getPassword( ) Method. 
 
8. Which list property do you set for specifying the items for the 
list? 
Answer: ​ model property. 
 
9. Which method would you use to determine the index of selected 
item in a list? 
Answer: ​ getSelectedIndex( ). 
 
10. How you can determine whether 5th item in a list is selected 
or not? 
Answer: ​isSelectedIndex(int) 
 
11. Which property you will set to ensure that only one item gets 
selected in a list. 
Answer: ​selectedIndex( ) property. 
 
12. Which method you will use to display a picture on a Label? 
Answer:​ import.javax.swing.ImageIcon 
 
13. Which method would you like to disable a push button 
jButton1?  
Answer: ​setEnabled(false) 
 
14. Which property would you like to set to make a Combo 
editable? 
Answer: ​editable property 
 
15. What are containers and child controls? Give two examples of 
each. 
Answer: ​A control which holds other component (child) controls, 
is called Container Control e.g. JFrame, jPanel, jDialog etc. 
 
 
16. How are keywords different from identifiers? 
Answer: ​Keywords are the reserve words that have a special 
meaning to the compiler. 
Identifiers are fundamental building block of program and 
used as names given to variables, objects, classes and functions etc. 
 
 
 
17. What is difference between / and % operator. 
Answer: ​/ is an escape sequence and % a character. 
 
18. Which of the following are valid identifiers and why/why not? 
 
My_rec, _Amt, 1 data, Amount 1, my.file, switch, goto, break 
Answer: ​My_rec - Valid 
_Amt - Invalid 
1 data - Invalid 
Amount 1 - Invalid 
My.file - Invalid 
Switch - Invalid 
Goto - Valid 
Break - Invalid 
 
 
 
 
19. How many types of integer constants are allowed in Java? How are 
they written? 
 
20. What kind of constants are the following: 
 
14, 011, 0X3A, ‘b’, 018, 0XBC1, “Amitabh” , ‘\n’ , “2/4” , “16/34 Old 
Cantt.” 
 
21. What type of result (int ot float) will be produced in Java, if a = 
5/3 is evaluated ? 
 
22. The expression 14%3 evaluates to _______. 
 
23. What will be the value of j = --k + 2*k + l ++ , if the value of k is 20 
and l is 10 initially? 
 
24. Evaluate P=P* ++ J where J is 22 and P = 3 initially? 
 
25. Write equivalent Java expressions for the following expressions: 
 
(i) ab + 1⁄2 cd2 
 
(ii) (a + b)2 
 
+ (c+d)4 
 
(iii) (a2 
 
+b2 
 

 
26. What is the significance of a break statement in a switch 
statement? 
 
27. Write one limitation and one advantage of a switch statement. 
 
28. What is the significance of default clause in a switch statement? 
 
29. What is the significance of ‘ linewrap’ property of text area control 

 
30. What is the significance of a button group control ? How do you 
create and use button group ? 
 
31. What methods obtains the current selection of a combo box ? Give 
a code example. 
 
32. What are iteration (looping) statements? Name three iteration 
statements provided by Java. 
 
33. What is meant by Entry-controlled and exit-controlled loop? Write 
one example of each. 
 
34. Write a for loop that displays the numbers from 10 to 1 i.e., 10, 9, 
8...., 3, 2, 1. 
 
35. Which method would you invoke to display 
 
(i) Message dialog (ii) confirm dialog (iii) input dialog 
 
36. Which methods are used to insert and remove rows from an 
existing table? 
 
37. What type of value is returned by Confirm Dialog? 
 
38. What is the size of following data types (i) int (ii) float (iii) double 
(iv) char (v) byte 
 

You might also like