This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes SCJP Question confusion example � need suggestion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "SCJP Question confusion example � need suggestion" Watch "SCJP Question confusion example � need suggestion" New topic
Author

SCJP Question confusion example � need suggestion

Nitin Bhagwat
Ranch Hand

Joined: Sep 09, 2004
Posts: 132
This is sample mock exam question:

When Integer object created at line 11 eligible for garbage collection?

10.public Object method1() {
11.Object ob = new Integer(30);
12.Object [] oo = new Object[1];
13.oo[0] = ob;
14.oo = null;
15.ob[0] = null;
16.print 'return 23';
17.}

A. Just after line 13
B. Just after line 14
C. Just after line 15
D. Just after line 16 (as method returns)

Ans given is C.
Actually, this program will not compile because, 1.No main method
2. line no. 16 will produce error.

My question is:
1. In real exam, if main method is not given, should we assume that?
2. If statement like 16 is wrong and program will produce error. So, actually we can not select any option.
3. In real exam, do we need to check errors like { } has correct start and end
4. Do we need to check if ; is added or missed for some statement

It would be nice if some one can tell, what should we do in above two cases in actual Exam?


"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Keep to the well established Mock exams. This one is clearly rubbish.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Atul Chandran
Greenhorn

Joined: Oct 24, 2004
Posts: 22
It is just a snippet. And the absence of main method will never result in a compile time error it will only result in a runtime error. Line 15 will result in a compile time error because ob is not an array(It should have been ob=null) and I have no idea about line 16..
Kailas Lovlekar
Ranch Hand

Joined: Oct 25, 2004
Posts: 34
1. In real exam, if main method is not given, should we assume that?

Probably yes! Sun exam guidelines say you can assume that supporting code exists id it is a partial code. Because this is not a complete class you may assume that main method exists probably with other methods

2. If statement like 16 is wrong and program will produce error. So, actually we can not select any option.

No chance of this happening in real exam!

3. In real exam, do we need to check errors like { } has correct start and end
4. Do we need to check if ; is added or missed for some statement

Real exam does try to trick you on some questions and only way to prepare for that is through good mocks! Not mocks containing questions like this!


SCJP/SCWCD/SCEA/OCA/Pega System Architect
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Someone correct me if I'm wrong, but I believe that you only have to look out for a compiler error if that is one of the choices.


Mike Gershman
SCJP 1.4, SCWCD in process
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SCJP Question confusion example � need suggestion