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

datatypes in java

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know only 2 datatypes in java

1. Primitive data types
2. Reference data types

I have been told in some interview that there is 3 rd also ..

Does anybody have idea about that.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the exact wording of the question might matter. Either that, or the interviewer was having you on, to see how well you'd argue your corner.

Variables and fields in Java are either object references or not object references. The term for any that aren't object references is "primitive". There are several primitive data types: int, float etc.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Java Language Specification says

There are two kinds of types in the Java programming language: primitive types (�4.2) and reference types (�4.3).

That's the second edition which comes up at the top of my Google search, but I don't think Java has been changed to include any new types since then.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by wrushasen dakhane:
... I have been told in some interview that there is 3 rd also ...


My response to that would have been: "What?"
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The third edition words it a little differently but the meaning is still the same.

The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types (�4.2) are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types (�4.3) are class types, interface types, and array types. There is also a special null type. An object (�4.3.1) is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object (�4.3.2). String literals are represented by String objects (�4.3.3).

http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html
 
Well THAT's new! Comfort me, reliable tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic