• 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
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

SCJP K&B Chapter 4 Question 8

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering how a person might go about solving the riddle on page 312 of the K&B book in under 3 minutes.

Place the fragments into the code to produce the output 33. Note, you must use each fragment
exactly once.

CODE:
class Incr {
public static void main(String[] args) {
Integer x = 7;
int y = 2;

x ___ ___;
___ ___ ___;
___ ___ ___;
___ ___ ___;
System.out.println(x);
}
}

FRAGMENTS:
y y y y y x x
-= *= *= *=
 
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Karen,

Welcome to Javaranch. I must admit that I found that question a little frustrating too. From what I understand, you're very unlikely to encounter a question like that on the real exam. But in the unfortunate event that you do, I suggest that you just leave it till after you've confirmed your answers to all the other questions. If all goes well, you should have at least 20 min remaining then, which will hopefully be enough to solve the puzzle. If not, well, 71/72 is a great score too.

The Whizlabs mock exams contain a similar puzzle-like question, which I just skipped entirely during my preparation. Honestly, I wouldn't waste too much time on questions like these. At the end of the day, the SCJP is all about developing and demonstrating your Java proficiency, so don't let the occasional oddball question discourage you.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Karen:

I think in the same way, when I saw that question in the book i said, "this output is really possible? What i'm supposed to be a SCJP or a Mathematic?" Have you the answer?
 
Karen Marie
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alejandro, nope. The answer appears to be "you probably won't see questions like that on the exam". Cross your fingers.
 
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Karen,

Your post is a good one. I've trying to solve some of the exercises in the SCJP 5 book. And many of them just are too tough. And I have been wondering with a big deal of concern if questions with this level of difficulty are actually in the real exam.
I sure hope NOT. Puzzles like this have at times totally discouraged me.
But it's good to know I'm not the only who's had trouble with them.

Good Luck Karen.
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Karen,

I was also frustrated by this very same question not too long ago. You might want to read my old post , which also has a link to another older post, and (if you search some more) there are other posters here who say similar things.

You are not alone. As Kelvin says, I wouldn't worry either.

Cheers,
Marcus
 
Alejandro Galv�n
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Karen:

First, sorry about the long time. I had been working very hard and I didn�t have time to login here, but I�m back, I studied with other book, and the problem might be wrong writed, because the same question have a difference in the operators, it gave:
-=
=
*=
*=

and the answer is:

x *= X;
Y *= Y;
Y = Y;
x -= Y;

it gives the expected output

Hope this still help you
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Karen Marie,
Whizlabs has a new product called Devsquare in this product you can practice the code i.e. write, compile and execute programs.

Regards
Sudeepa

Whizlabs Software
Success, certified!
World's BEST Java Certification Preparation Solutions
SCJA| SCJP 5.0 | SCJP 5.0 (Training))| SCWCD SCBCD | SCDJWS | SCEA | SCMAD
With Unconditional 150% Test PASS Guarantee!
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

Stepping back from this particular question, and looking at the high view of the exam:

1 - You will definitely spend more time on some questions than on others. (For instance some of the threads questions have a lot of code to look through.) So you can't expect that you'll never have to spend more than 2 or 3 minutes on any given question - you'll have to budget your time! In other words, sometimes you might answer a question in 30 seconds, and other times you might spend 5 or 7 minutes.

2 - This puzzle-y kind of question probably won't come up often, but you might get one or two like this so we just wanted you to be prepared. Also, there aren't any "fill in the blank" questions like this one, we were just trying to emulate a drag-and-drop question in a book :roll:

hth,

Bert
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic