• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

&sim operator

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I took one of the many tests out there and got this question:


Which of the following lines of code, considered individually, compile(s) without error? Choose all correct options.
A) int i=1; int j = &simi;
B) int i=1; int j = !i;
C) boolean b = true; boolean c = &simb;
D) boolean b = true; boolean c = !b;


I had no idea the &sim operator existed, so I answered D. But apparently, this was the correct answer:


Correct selection is: A, D
The &simoperator performs bitwise inversion on integral types; it may not be applied to boolean data. The ! operator inverts boolean values; it may not be applied to integral types.


Can anyone explain what the &sim operator is? Where can I find more information on it? Are there more operators like this one?
--
Christoffer
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you talking abt ~ operator?
- Manish
[ May 30, 2002: Message edited by: Manish Hatwalne ]
 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Christoffer
You answered correct - A is wrong answer!
There is no sim operator in Java ! Try compile this code and you'll be sure in this.
Where you found this test? This is not correct test.
Jamal Hasanov
www.j-think.com
 
Christoffer Jeffson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, it must have been the ~ operator. The makers must have forgot the ; when typing ∼
 
Sheriff
Posts: 17710
302
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a known error in one of the RHE mock exams. Look in the errata forum.
 
Lookout! Runaway whale! Hide behind this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic