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 3 of 7.

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)

Nancy said:   1 decade ago
Every class in java is also a data type itself. Since Dog is a user defined class, it is a user defined data type also.

Suganthan.M said:   1 decade ago
Dog - There is no primitive datatype like 'Dog'. It is a User Defined type. By default it will hold null value.

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)

Dipen said:   1 decade ago
How did you all came to know that '/u0000' is hex and what is exactly char default value null or space??

Mahi said:   1 decade ago
Hello Character default value nothing here '\u0000' mention how correct options 4 please explain sir?

Shaswati said:   1 decade ago
How option 4 is correct? I could not understand. Please explain about the default data type of char.

Pradeep Yadav said:   1 decade ago
Please explain me how can we get the value of class (Dog) object with array in main method from Dog?

Bhavani said:   1 decade ago
The default value for float is only 0.0 in the given question it is 0.0f.

How option B is correct?

Manju said:   1 decade ago
What are default value of char in C++?

What is \u0000? What does \u indicate?

Please explain.


Post your comments here:

Your comments will be displayed after verification.