• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

best strategy to answer this question??

 
sabah ammar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry.. i just got misunderstood with the converstion, i...obviously know the hex-bin conversion.. thanks again.
 
Jay Pawar
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 )
 
sabah ammar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is something smart
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay ,
Have you ever prepared for MBA entrance ...
 
Jay Pawar
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But you should go for that ...
I am in Pune .
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Maciej Gulak
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic