Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8847703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:15:12+00:00 2026-06-14T12:15:12+00:00

I am going through The Java Handbook by Patrick Naughton. Book says: When you

  • 0

I am going through “The Java Handbook” by Patrick Naughton.

Book says: When you declare the type of a variable to be a class, it has a default value of null which is a reference of type Object, and is thus type-compatible with all the other classes. The null object has no value; it is distinct from the integer 0, just like boolean’s false.

I cannot understand/confuse the highlighted part, does it say that null is a variable of type Object?

Page no: 107
para: 5

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:15:14+00:00Added an answer on June 14, 2026 at 12:15 pm

    It’s a reference value, not a reference variable. Any variable that is a reference type can have the value null. (In Java, all variables are either reference types or primitive types (int, char, float, etc.). (Well, there are also type variables when you start to talk about generics.)

    Here’s the relevant part of the Java Language Specification:

    There are two kinds of types in the Java programming language: primitive types (§4.2) and reference types (§4.3). There are, correspondingly, two kinds of data values that can be stored in variables, passed as arguments, returned by methods, and operated on: primitive values (§4.2) and reference values (§4.3).

    There is also a special null type, the type of the expression null (§3.10.7, §15.8.1), which has no name.

    Because the null type has no name, it is impossible to declare a variable of the null type or to cast to the null type.

    The null reference is the only possible value of an expression of null type.

    The null reference can always undergo a widening reference conversion to any reference type.

    In practice, the programmer can ignore the null type and just pretend that null is merely a special literal that can be of any reference type.

    EDIT To address your comment: I think the language in "The Java Handbook" is a little off the mark. The value null is not a reference of type Object; it is a reference of the null type. The key point from the spec is that "the null reference can always undergo a widening reference conversion to any reference type". This is, in a sense, exactly the opposite of Object. An Object reference is the widest type of reference; the null type is (to also speak a little loosely) the narrowest. In particular, assigning a reference of type Object to a variable of any other reference type is a narrowing conversion that requires an explicit cast (and can raise a ClassCastException). Assigning the null reference to a variable of any reference type never requires a cast and cannot raise an exception.

    Note that no named reference type can have the behavior of the null type. There really is no "narrowest type" since the (named) type system in Java does not not have such a thing. It is impossible to define a reference type that is assignable to, say, both a String variable and a Double variable. Only the null type has that property. The normal rules for reference type conversion do not allow this, which is why it has a separate rule in the Java Language Specification.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I'm going through the Friedman & Felleisen book A Little Java, A Few
I'm going through the book Just Java 2 but am evidently missing something basic.
I was going through the Calendar class source code in the Java API, and
I am going through a java 6 book. A sample code snippet is given
I'm going through a book on Java and I've been understanding most of it
I have the following query , I was going through Java immutable class concept
I am going through the oracle API for java.io.RandomAccessFile class. There's method called read()
I was going through some Java tutorials in a book and ran across code
I was going through java class in which I found all the methods were
I’m just really learning Java, going through tutorials in book Java how to Program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.