aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes 2 questions from jQ+ mock-some misunderstandings 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 "2 questions from jQ+ mock-some misunderstandings" Watch "2 questions from jQ+ mock-some misunderstandings" New topic
Author

2 questions from jQ+ mock-some misunderstandings

Cristi Tudose
Ranch Hand

Joined: Dec 25, 2000
Posts: 53
Q1. Which of the following will add a Component 'comp' to a container 'c', if it's layout is governed by GridLayout 'g'?
Select all 3 correct choices:
1.c.add(comp);
2.c.add("Center",comp);
3.g.add(comp);
4.g.addLayoutComponent("CompName",comp);
5.c.add(comp,-1);
I checked 1,2,5(even 2. .They gave correct answers as 1,4,5.
Please an explanation.
Q2.Which of the following statements about hashCode() method of Object class are true?
Select all 2 correct choices:
1.is a native method;
2.it return int;
3.it return long;
4.it cannot be overriden;
5.none of the above.
To me only 2 seem correct answer.
API states ublic int hashCode();
if I run javap java.lang.Object the definition is public native int hashCode().For the exam purpose should I know this?
Please confirm.
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
For the second question, it is int and native. The API doesn't tell you when it is native because it shouldn't matter to the programmer whether it is native or not.
As for whether or not you need to know this, well it is part of the objectives, so yes they could ask you something like this. I don't know if they will get that detailed as to wanting to know if a method is native or not, but that is why mocks help so much. Things you wouldn't read or pick up, can be brought to light.
Bill
Anshuman Acharya
Ranch Hand

Joined: Jan 19, 2001
Posts: 144
for the first, ichecked 1 and 4.
about addLayoutComponent :
addLayoutComponent
public void addLayoutComponent(String name,
Component comp)
Adds the specified component with the specified name to thelayout.
Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name - the name of the component.
comp - the component to be added.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi,
For question 1, number 5 is also correct. The Container class supports two add methods:
add( Component comp);
add( Component comp, int index );
Index in the second one is the position of the new component. The value of -1 places the comp at the end (the default!). So number 5 is exactly the same as 1!
Regards,
Manfred.
Cristi Tudose
Ranch Hand

Joined: Dec 25, 2000
Posts: 53
definetly 1,5 are correct
and i say 2 works fine also

so,why choice 2 is not a valid answer?
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Cristi,
I think 2 is not shown as a valid answer to the question because it shows bad Java programming. Usually the literal Strings:
"North", "South", "West", "East", and "Center" are used when adding components into a BorderLayout.
I am not saying it won't work. In your example, the literals are being accepted as component names. I also don't think that the real exam would have any such ambiguity!
Regards,
Manfred.
Cristi Tudose
Ranch Hand

Joined: Dec 25, 2000
Posts: 53
Hi Manfred,
what about choice 4?
rgds,
cristi
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3204
    
    2
Please give the question id. I'll check it out.
-Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 2 questions from jQ+ mock-some misunderstandings
 
Similar Threads
Khalid Mock - Hashcode Q
JQ+:Question ID :954959231549
hashCode() Question?
Question about hashcode()
Operators