• 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

Boone #50

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
What does the following line of code do?
TextField tf = new TextField(30);
Select the one right answer.
a.This code is illegal; there is no such constructor for TextField.
b.Creates a TextField object that can hold 30 rows, but since it is not initialized to anything, it will always be empty.
c.Creates a TextField object that can hold 30 columns, but since it is not initialized to anything, it will always be empty.
d.This code creates a TextField object that can hold 30 rows of text.
e.Creates a new TextField object that is 30 columns of text.
I thought the answer is C but it came out as E. Isn't it empty textfield with 30 column capacity.
Any comments are welcome.
Thanks
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The trick here is that they say it will ALWAYS be empty. You can set the text of the textfield so it won't always be empty, it will just initially be empty.
By the way, Jay S is not a name that comforms to our naming conventions here at the ranch. Please re-register with a more appropriate name. Take a look at this page, www.javaranch.com/name.jsp for more info.
Thanks,
Bill
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jay,
The answer is e only because if you want to make the textfield
empty you specify in the constructor as new TextField("",30)
This is the right way to make empty.

Regards
Lala
 
reply
    Bookmark Topic Watch Topic
  • New Topic