aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Passed Mock Exam with 75% --> Some questions about wrong answers... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Passed Mock Exam with 75% --> Some questions about wrong answers..." Watch "Passed Mock Exam with 75% --> Some questions about wrong answers..." New topic
Author

Passed Mock Exam with 75% --> Some questions about wrong answers...

Kai Wähner
Ranch Hand

Joined: Sep 16, 2009
Posts: 76
Hi there,

I just made the first mock exam from the SCJP book. Some questions occurred, where I am a little bit unsure:


1) If I use , do I still access the Strings with agrs[0], agrs[1] and so on?




2) Method: --> if z has the value 3, the method call returns 3, not 4, right?




3) --> the go method has "void" as return value, so that is not possible (because it does not return anything. But what else is not allowed? I do not understand this?
Does String s; or String s = "test"; return anything? Can someone please explain me this rule?




4) I thought that an interface declaration MUST be declared public? (I know that methods are declared public abstract implicitly, and constants are declared static final implicitly)




5) Why does USUALLY the developer throw the NumberFormatException? I never did :-) Isn't this thrown USUALLY by the JVM (e.g. when I divide 10 through 0), just like NullPointerException, ClassCastException, and so on?




6) Can you please explain me the "switch and final" rule?
final int x = 3 may be used as switch expression, but short = 3 must not? Why?





I think with 75% in this mock exam (although I have seen some of the questions before), I am on a good way - with some more learning I am ready to try the exam :-)

I just downloaded the "ExamLab for SCJP 6.0" - do you think this is the best way now to improve my knowledge at this point?


Best regards,
Kai

My IT-blog about my experiences with: Java / JEE, IT Conferences and IT Certifications

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

1) yes
2) yes
3) The second part of assert statement after : cannot have a call to a method returning void. See this
4) Interfaces are not required to be declared public
5) ArithmeticException is thrown when 10 is divided by 0 not NumberFormatException. NumberFormatException is generally thrown by parseXXX methods like parseInt to indicate that the parsed String cannot be parsed into a number.
6) I cannot understand this question of yours. You've written short = 3 which is not even a legal java syntax...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Kai Wähner
Ranch Hand

Joined: Sep 16, 2009
Posts: 76
Thanks for your quick reply.

Assert:
Expression2 is an expression that has a value. (It cannot be an invocation of a method that is declared void.)

Ok, so the second expression can be anything else, but not a call to a method that is declared void?




Question 6 again, sorry for my mistake:
Can you please explain me the "switch and final" rule?
final int x = 3 may be used as switch expression, but short y = 3 must not? Why? e.g:



Why fails the second example and what is the specific rule to remember? Does a switch expression always have to be declared final or be an Enum?


Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Kai Wähner wrote:
.........



Why fails the second example and what is the specific rule to remember? Does a switch expression always have to be declared final or be an Enum?



Does this fail? switch expression need not be a final, but the case!


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Kai Wähner
Ranch Hand

Joined: Sep 16, 2009
Posts: 76
Does this fail? switch expression need not be a final, but the case!


Oh, ok. You are right. So only the case expression must be final or a Enum...
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Kai Wähner wrote:
Does this fail? switch expression need not be a final, but the case!


Oh, ok. You are right. So only the case expression must be final or a Enum...


If you've enough time, and knowledge hungry, have a look on this
Kai Wähner
Ranch Hand

Joined: Sep 16, 2009
Posts: 76
Sure, I am knowledge hungry :-) Thanks...
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

As for assert statement, you cannot put "anything" after : in assert statement. It should be an expression which returns a value. Check the documentation of AssertionError class, it has a number of constructors which take primitive types and Object as argument. So the part after : can be anything which returns a primitive or Object as a value...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passed Mock Exam with 75% --> Some questions about wrong answers...