| Author |
JQplus Ques
|
Mini Pilla
Ranch Hand
Joined: Jul 15, 2001
Posts: 112
|
|
Can somebody plz explain the output!!! Thanx import java.awt.*; public class TestClass extends Frame { TestClass( ) { setLayout(new FlowLayout()); CheckboxGroup[] cbgs = new CheckboxGroup[] { new CheckboxGroup(), new CheckboxGroup()}; for (int i=0; i<5; i++) add( new Checkbox("Checkbox"+i, true, cbgs[i%2] ) ); setSize(300, 300); setVisible(true); } public static void main(String[ ] args) { new TestClass(); } } 1.All check boxex 2.None of the check boxex 3.Throws runtime exception 4.check boxes labeled Checkbox0,Checkbox2 5.check boxes labeled Checkbox3,Checkbox4 Ans: Only one checkbox can be selected in a checkboxgroup. As you go on adding checkboxes to a group in selected state, it unselects the previously added checkboxes. Here, Checkbox 0,2,4 are added to cbg[0] and Checkbox 1 3 are added to cbg[1]. So Checkbox 4 and 3 remain selected.[/B]
|
 |
Mini Pilla
Ranch Hand
Joined: Jul 15, 2001
Posts: 112
|
|
helloo, Nobody wants to attempt
|
 |
Paul Anilprem
Enthuware Software Support
Ranch Hand
Joined: Sep 23, 2000
Posts: 2912
|
|
Well, what exactly do you not understand. As the explanation says only one one checkbox of a checkbox group can be selected. So out checkbox 0,2,4 4 will remain selected and out of 1 and 3, 3 will remain selected. cbgs[i%2] : i%2 will only return 0 or 1 so each checkbox goes to either checkboxgroup 0 or 1. -Paul. ------------------ SCJP2 Resources, Free Question A Day, Mock Exam Results and More! www.jdiscuss.com Get Certified, Guaranteed! www.enthuware.com/jqplus Your guide to SCJD exam! www.enthuware.com/jdevplus
|
Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
|
 |
 |
|
|
subject: JQplus Ques
|
|
|