File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes datatypes in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "datatypes in java" Watch "datatypes in java" New topic

datatypes in java

wrushasen dakhane
Ranch Hand

Joined: Sep 25, 2006
Posts: 47
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.

SCJP 1.4, SCWCD 1.4
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

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.
marc weber

Joined: Aug 31, 2004
Posts: 11343

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?"

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2398
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).
I agree. Here's the link:
subject: datatypes in java
jQuery in Action, 3rd edition