• 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

mock question from appliedreasoning.com

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 289
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. Herbert is right.
 
chafule razgul
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Herbert i got it now
 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic