• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passed SCJP 1.4/Help With Question on Exam

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Congratulations Piyush!
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Congratulations Piyush
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
This tiny ad will self destruct in five seconds.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic