This week's giveaway is in the Spring forum.
We're giving away four copies of liveProject: Protecting User Data with Spring Security and OAuth2 and have Laurentiu Spilca on-line!
See this thread for details.
Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Marcus Green - What is Java Integral Type

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LINK: http://www.jchq.net/mockexams/exam3.htm

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

============
Here Marcus Green's answer was just 3. I also feel that 4 is correct. If I am wrong, then can someone tell me, what does "Java Integral Type" means ???
[ November 08, 2004: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Manikandan,
I feel char primitive data type which is 16 bit is internally treated as integer. char is unsigned data type, hence the option 4 is not correct.
byte, short, int, long, char are all integral types meaning they are internally treated as integers.
Experts correct me if I've stated a wrong statement.

Hope this helps you
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why wait for an expert when you can be one yourself? From the Java Language Specification:


4.2.1 Integral Types and Values
The values of the integral types are integers in the following ranges:

* For byte, from -128 to 127, inclusive
* For short, from -32768 to 32767, inclusive
* For int, from -2147483648 to 2147483647, inclusive
* For long, from -9223372036854775808 to 9223372036854775807, inclusive
* For char, from '\u0000' to '\uffff' inclusive, that is, from 0 to 65535

 
Jay Pawar
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Barry. I remember reading the stuff in K&B book but I guess once in a while I should peek in JLS too.
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good question Manikandan, thanks for the follow ups everyone. It is a good reason for me to put in heaps of hyperlinks on terms, after all that is what the web was designed for. So the answer should have been something like

bla bla bla
integral types bla bla

For some wierd reason the college where I work has banned that page, surely nothing saucy about integral types is there?)
[ November 08, 2004: Message edited by: Marcus Green ]
 
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic