Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes mock question from appliedreasoning.com Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "mock question from appliedreasoning.com" Watch "mock question from appliedreasoning.com" New topic
Author

mock question from appliedreasoning.com

chafule razgul
Ranch Hand

Joined: Feb 09, 2002
Posts: 63
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

Joined: Feb 09, 2002
Posts: 63
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

Joined: May 03, 2000
Posts: 289
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

Joined: Jan 31, 2002
Posts: 5
Yes. Herbert is right.
chafule razgul
Ranch Hand

Joined: Feb 09, 2002
Posts: 63
Thanks Herbert i got it now
Rajinder Yadav
Ranch Hand

Joined: Jan 18, 2002
Posts: 178
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 ]

<a href="http://www.rajindery.com" target="_blank" rel="nofollow">Rajinder Yadav</a><p>Each problem that I solved became a rule which served afterwards to solve other problems. --Rene Descartes
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mock question from appliedreasoning.com