This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passed SCJP 1.4/Help With Question on Exam

 
Piyush Jain
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I passed the SCJP exam yesterday with 81%.

the questions were all ok, except one that i could not think an answer for.

I don't remember it completely, but there was a statement between the try and catch, and should be giving a compiler error. However, the question was a short answer one and value of a string variable was asked. it looked somethng like this:

public class Class
{
String counter = "";

void foo(int i){
try
{
if(i==0)
throw new Exception();
}

counter += "1";
catch
{
//some code
}
finally
{
//some code
}
}
public static void main(String [] args)
{
foo(1);
foo(0); //*****
}

}

what is the value of variable counter at //*****

My preparation:

I have done a little Java a year ago, where I worked on an application using Java RMI and C++ to control robots through web.

Read HeadFirst Java, last week started reading Java Certification Book by Kathy S. and Bert B., really nice book, though I couldn't use it thoroughly, but I would have got a better score had i bought it earlier. I will highly recommend this book to anybody preparing for the exam.

And ofcourse, this forum, which cleared by hidden doubts about everything.

I am going for SCBCD now, and would like people's preparation recommendations.

Thanks
[ September 13, 2004: Message edited by: piyush jain ]
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Congratulations Piyush!
 
Jitin Narang
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Congratulations Piyush
 
Saravanarajan Rajamuthu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
COngrats piyush...

Hey ! The code snippet that you have given wont compile, as the static main method can't call the non static method foo()..
 
Piyush Jain
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all.

Thats what I thought about the code sarvana,but it was in the test and it was not a MCQ, a short answer one, which asked the value of the counter variable.

Anybody knows what would have been the answer for the question, if it can't compile, then question is probably wrong, and SUN should not be penalizing me for that question.

Any comments?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic