• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Boone #50

 
Jay S
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • 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
 
Lala Viswanath
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic