Java Programming - Language Fundamentals - Discussion

Discussion Forum : Language Fundamentals - General Questions (Q.No. 1)
1.
Which four options describe the correct default values for array elements of the types indicated?
  1. int -> 0
  2. String -> "null"
  3. Dog -> null
  4. char -> '\u0000'
  5. float -> 0.0f
  6. boolean -> true
1, 2, 3, 4
1, 3, 4, 5
2, 4, 5, 6
3, 4, 5, 6
Answer: Option
Explanation:

(1), (3), (4), (5) are the correct statements.

(2) is wrong because the default value for a String (and any other object reference) is null, with no quotes.

(6) is wrong because the default value for boolean elements is false.

Discussion:
64 comments Page 2 of 7.

Subhash said:   10 years ago
Int-0.
Float-0.0f or 0.0F.
Char-'\u0000'.
Boolean-False.
Byte-0.
Short-0.
Long-0.
Double-0.0 or 0.0d or 0.0D.
(1)

Indu said:   9 years ago
Please explain the difference between the method overloading and method overriding?
(1)

Muthamil.A said:   1 decade ago
char default value "space" in java .
char default value \u0000 in c.
dog s a object so that default value null.
(1)

Abhi said:   9 years ago
Why option 2 is wrong?
(1)

AVINASH said:   9 years ago
Int-0.
Byte-0.
Short-0.
Long-0.
Double-0.0 or 0.0d or 0.0D.
Float-0.0f or 0.0F. Here f means float type default value 0.0.
Char-'\u0000' or space.
Boolean-False.
String - null.
(1)

Senthil said:   9 years ago
The string default value is null.

So, why option 2 is wrong?
(1)

Sireesha said:   9 years ago
What is that \u declared in char?
(1)

ShriKrishn Sharma said:   1 decade ago
Default value of char is "null space" it's Unicode is 32. If you want to print it using println function you get a white space over there.

Anonymous said:   9 years ago
Dear Sundar.

It's a static String which not consist quotes. Dog.

Shrikrishn Sharma said:   1 decade ago
Char's default value is not NULL nor 0 in Java.


Post your comments here:

Your comments will be displayed after verification.