aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes best strategy to answer this question?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "best strategy to answer this question??" Watch "best strategy to answer this question??" New topic
Author

best strategy to answer this question??

sabah ammar
Greenhorn

Joined: Jan 10, 2005
Posts: 23
hi pals,
can someone please tell me how can i use method of elimination for questions like this, because i believe i cant solve the whole of it during the exam, or if u ve got some other better way to have it done correct!! thank you.

public class Test{
public static void main(String args[]){
int i=oxFFFFFFF1;
int j=~i;
}}

which is decimal value of j at line 5?
A. 0
B.1
C.14
D.-15
E. compile error at line 3
F. compile error at line 4
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Here is how I approach this problem.

FFFFFFF1 in hexadecimal is
11111111 11111111 11111111 11110001 in binary

~i means to replace every 0 bit with a 1 bit and replace every 1 bit with a 0 bit, so ~i is
00000000 00000000 00000000 00001110 in binary, which is 14 in decimal

If I can't do a bit manipulation problem quickly in my head, I do it in binary, not in hexadecimal.


Mike Gershman
SCJP 1.4, SCWCD in process
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by sabah ammar:
3: int i=oxFFFFFFF1;
...
E. compile error at line 3
If that really is a lowercase o and not a leading 0 before the x, then the answer is E.
sabah ammar
Greenhorn

Joined: Jan 10, 2005
Posts: 23
mike thank you for the simple answer but it lead me to this one more question.can u please explain the method to convert hex - binary?
sabah ammar
Greenhorn

Joined: Jan 10, 2005
Posts: 23
sorry.. i just got misunderstood with the converstion, i...obviously know the hex-bin conversion.. thanks again.
Jay Pawar
Ranch Hand

Joined: Aug 27, 2004
Posts: 411
One more tip . If the question asked is in decimal form like this

then the value of k can be calculated as k = - ( j + 1 )


Cheers,<br />Jay<br /> <br />(SCJP 1.4)<br />Heights of great men were not achieved in one day, they were toiling day and night while their companions slept.
sabah ammar
Greenhorn

Joined: Jan 10, 2005
Posts: 23
this is something smart
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Jay ,
Have you ever prepared for MBA entrance ...
Jay Pawar
Ranch Hand

Joined: Aug 27, 2004
Posts: 411
Originally posted by rathi ji:
Jay ,
Have you ever prepared for MBA entrance ...


My dad wanted me to do that. not me BTW where are you in India?
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
But you should go for that ...
I am in Pune .
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

My dad wanted me to do that


Might be this is a bit off topic, however, personally, I believe MBA is a must nowadays for entering into management level with a easier career path.

MBA did offer you a good chance to meet with different people from different companies. And if the MBA programme is highly recognized, it really helps you to build a "network" that benefits much in your career path as you might meet "powerful" guys.

Of course, you need to have experiences on how to manage people. As said all the time, getting a certificate with no experience means nothing at all.

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Maciej Gulak
Greenhorn

Joined: Mar 07, 2005
Posts: 2
Hi Jay,

I think you wanted to type '-' instead of '+'.

For example, JLS says: "[...] note that, in all cases, ~x equals (-x)-1"

br,
Maciej
 
jQuery in Action, 2nd edition
 
subject: best strategy to answer this question??