• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

answers to java.ditmas.net Mock Exam

 
Moya Green
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did the mock exam provided by http://java.ditmas.net/mocks.htm. Does anyone know where are the updated (corrected) answers to the mock exam? Some of the answers seem to be not right. Or maybe I am wrong.
Thanks!
 
Jim Petersen
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Moya
Just to let you know there are some incorrect answers on that site from what I remember when I did the SCJP
 
chafule razgul
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For #43 i have a question
43. What will be the return type of this statement?
(byte)10/10.2*7;
A. short
B. int
C. double
D. float
E. Compilation Error
My question is,the priority of the cast operator, what is actually being casted into byte?
TIA
 
Curly Bloke
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It returns a double (see http://java.sun.com/docs/books/tutorial/java/nutsandbolts/expressions.html for a summary of operator precedence) as the cast is evaluated before the / and *
 
chafule razgul
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Curly
FYI, questions 50 and 55 have incorrect answers, in my opinion, after trying them out.. Question 32 has options A-D, but the answer is E..
 
Marcus Howarth
Ranch Hand
Posts: 38
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree
#50 - C: Exception is a subclass of Throwable - not Thread as they seem to think
#55 - Given:

How will you create an instance of static Inner Class? Select 2
a. Inner a= new Inner();
b. Outer o= new Outer();Outer.Inner a= new o.Inner();
c. Outer.Inner a= new Outer.new Inner();
d. Outer.Inner a= new Outer.Inner();

they say B & D.. I would have said B for sure.. when run in the main() but does D work?
# 32 - yeah well.. nice answer! no option E.. I'm about to give up on this test I think.. though good practice! but just to check I've got it

What will be the output?
A. Compilation Error void main Can't return any value.
B. Prints Exception
C. Prints Exception Finally
D. Prints Finally

answer is A right?
PS. can you see the question numbers for the answers? I've had to copy it into a spreadsheet to see them...
 
Erik Dark
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#55 - Given:

How will you create an instance of static Inner Class? Select 2
a. Inner a= new Inner();
b. Outer o= new Outer();Outer.Inner a= new o.Inner();
c. Outer.Inner a= new Outer.new Inner();
d. Outer.Inner a= new Outer.Inner();

they say B & D.. I would have said B for sure.. when run in the main() but does D work?

Rule: A static member/nested class reference does not need an instance of the enclosing class!
According to this D is ok, B is right although it uses an instance of the Outer class.
Erik Dark
 
Brian Lugo
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For #32 correct answer is D.
Are you guys all talking about the same test?, i.e the one at:-
http://java.ditmas.net/mocks.htm
I will make sure I do not go to this web site when I am ready to take mock exams.
Thanks,
Brian
 
flynn xi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

#55 - Given code:
class Outer{
static class Inner{}
}
How will you create an instance of static Inner Class? Select 2
a. Inner a= new Inner();
b. Outer o= new Outer();Outer.Inner a= new o.Inner();
c. Outer.Inner a= new Outer.new Inner();
d. Outer.Inner a= new Outer.Inner();
they say B & D.. I would have said B for sure.. when run in the main() but does D work?

Just tried choice b: it makes compiler complain about no package o. But if you change "a = new o.Inner()" to "a = o.new Inner()", then no compiler error at all! :roll:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic