• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Check Boxes??

 
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 CheckBoxes
2)None of the CheckBoxes
3)It will throw RunTimeException
4)The checkboxes labeled Checkbox0,Checkbox2
5)The checkboxes labeled CheckBox3 and CheckBox4
Ans : 5)
According to me it should display the checkBox labeled 4(i.e last one)
Can any one explain me the question and the answer?

 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sonir,
I was never any good at Jeopardy ...
Since you didn't give us the question, I can't explain anything to you ...
However, I can say that the FlowLayout manager will display all the checkboxes. THerefore the resulting Frame will contain 5 checkboxes named CheckBox0, CheckBox1, ... CheckBox4.
Regards,
Manfred.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic