What is null?
Is null an instance of anything?
What set does null belong to?
How is it represented in the memory?
|
What is Is What set does How is it represented in the memory? |
|||||
|
No, there is no type which 15.20.2 Type Comparison Operator
|
|
|||
|
Null references existed in LISP (as
NIL) in 1960, and probably earlier. But I don't think Hoare is really trying to claim invention of null references in that quote.
– Stephen C
May 6 '11 at 7:09
|
||
|
Hoare is not trying to claim invention of null references; he is merely claiming that he made them available in a particularly influential place. There are many languages, including Java, that clearly took inspiration from Algol, and if their use of null references was even in part inspired by or copied from Algol, Hoare is correct in taking on some of the blame for the cost of these. I do feel, however, that his estimate is rather low. A trillion dollars might be closer to the true cost.
– Curt Sampson
Feb 2 '13 at 4:29
|
||
|
|||
|
No. That is why
It is the one and only member of the null type, where the null type is defined as follows: "There is also a special null type, the type of the expression null, 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 be cast 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." JLS 4.1
See above. In some contexts,
That is implementation specific, and you won't be able to see the representation of |
||||
|
|
|
What is null? It is nothing. Is null an instance of anything? No as it is nothing It can't be instance of any thing. What set does null belong to? No any set How is it represented in the memory? If some reference points to it like:
In heap memory some space assigned to new created object. And o will point to that assigned space in memory. Now This means now o will not point to that memory space of object. |
|||||
|
|
No it's not the instance of anything, instanceof will always be false. |
|||
|
|
|
The null keyword is a literal that represents a null reference, one that does not refer to any object. null is the default value of reference-type variables. Also maybe have a look at |
|||||
|
|
Null in Java(tm) In C and C++, "NULL" is a constant defined in a header file, with a value like:
or:
or:
depending on the compiler and memory model options. NULL is not, strictly speaking, part of C/C++ itself. In Java(tm), "null" is not a keyword, but a special literal of the null type. It can be cast to any reference type, but not to any primitive type such as int or boolean. The null literal doesn't necessarily have value zero. And it is impossible to cast to the null type or declare a variable of this type. |
|||
|
|
|
Null is not an instance of any class. However, you can assign null to variables of any (object or array) type:
|
|||
|
|
|
|
|||||||||
|
|
|
|||
|
|
|
Bytecode representation
Chapter 6 "The Java Virtual Machine Instruction Set " then mentions the effects of 2.4. "Reference Types and Values" also mentions
|
||||
|
|
|
An interesting way to see null in java in my opinion is to see it as something that DOES NOT denote an absence of information but simply as a literal value that can be assigned to a reference of any type. If you think about it if it denoted absence of information then for a1==a2 to be true doesn't make sense (in case they were both assigned a value of null) as they could really could be pointing to ANY object (we simply don't know what objects they should be pointing to)... By the way null == null returns true in java. If java e.g. would be like SQL:1999 then null==null would return unknown (a boolean value in SQL:1999 can take three values : true,false and unknown but in practise unknown is implemented as null in real systems)... http://en.wikipedia.org/wiki/SQL |
|||
|
|
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?