• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

true/false

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai friends,
this is a question from Maruce Green 3 could some one explain me the 4 option which is false integral
Which of the following statements are true?
1) The following statement will produce a result of 1. System.out.println( -1 >>>2);
2) Performing an unsigned left shift (<<< on a negative number will always produce a negative number result
3) The following statement will produce a result of zero, System.out.println(1 >>1);
4) All the Java integral types are signed numbers

thanking u
shyam
integral types
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you take a look at the JLS §4.2.1 Integral Types and Values, you'll see that the integral types include byte, short, int, long, and char. While byte, short, int, and long are all signed types, char is an unsigned type.
Therefore, because of char, the statement is false. Not ALL integral types are signed numbers.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by kumar shyam:
2) Performing an unsigned left shift (<<< ; ) on a negative number will always produce a negative number result


One other thing that caught my eye was this statement. There's no such thing as an unsigned left shift in Java. There is only 1 left shoft operator (<< while there are two right shift operators (>> and >>> .
I suppose you could call it an unsigned left shift operator as it does not guarantee that the sign of the resulting value won't change, but there is no reason to denote such a thing as there is only one left shift operator. Also, the correct lexicon for that operation is <<, not <<<.
 
Sham Grandhe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai Corey McGlone,
thank u for ur kind help. u have given me the exact pt what I wanted
regards
shyam
 
Thanks tiny ad, for helping me escape the terrible comfort of this chair.
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic