This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mock question from appliedreasoning.com

 
chafule razgul
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Panel has a GridLayout with 2 rows and 2 columns. There is a button in each of the cells and another button is added to the panel as follows:
aPanel.add(newButton("Bob")). Where will the new button be placed?
A. row 1 column 3
B. row 1 column 1
C. row 3 column 1
D. row 2 column 3
E. row 2 column 2
The answer says its row 2 column 2, should i think should be row 1 column 3. Can any one verify that the answer is correct/incorrect?
TIA
 
chafule razgul
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
another question also from the same site
What will happen when this code is compiled
1. import java.util.*;
2. import com.jane.Vector;
3. public class Test{
4. public static void main(String[] args){
5. Vector vector = new Vector();
6. vector.addElement("hello");
7. }
8. }
A. The compiler will object to line 2 stating that the Vector class is already defined.
B. The compiler will object to line 5 statiing that Vector is ambiguous.
C. The program will compile and at line 5 a new instance of the java.util.Vector class will be created.
D. The program will compile and at line 5 a new instance of the com.jane.Vector class will be created.

why is com.jane.Vector created?
 
Herbert Maosa
Ranch Hand
Posts: 289
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you add one more button than the grid would originally accomodate, one more column is added to the grid. When we have the additional column, the buttons will be rearranged, in the order in which they were added, from left to right, top to bottom. So the original 4 buttons will fill from row 1 column 1 to row 2 column 1. The new button then should be on row 2, column 2.
Herbert.
[ February 26, 2002: Message edited by: Herbert Maosa ]
 
Lakshmi Grandhi
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Herbert is right.
 
chafule razgul
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Herbert i got it now
 
Rajinder Yadav
Ranch Hand
Posts: 178
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nice question
>why is com.jane.Vector created?
because in your 2nd import statement you have a fully qualified package statement pointing to jane's Vector class
therefore the scoping rule allow you to access the Vector class with out ambiguity
if you would have used import com.jane.*; instead, then you would have run into trouble
[ February 26, 2002: Message edited by: Rajinder Yadav ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic