• 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

AWT qustion

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Container methods add( Component comp ) and add( String name, Component comp ) will throw an IllegalArgumentException if comp is a:
a) button
b) list
c) window
d) textarea
e) container that contains this container
what is the answer for the above.
Vrinda
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answer is C) and E)
This Code is taken from java.lang.Container class.
if (comp instanceof Container) {
for (Container cn = this; cn != null; cn=cn.parent) {
if (cn == comp) {
throw new IllegalArgumentException(
"adding container's parent to itself");
}
}
}
if (comp instanceof Window) {
throw new IllegalArgumentException(
"adding a window to a container");
}
 
Beauty is in the eye of the tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic