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?
- int -> 0
- String -> "null"
- Dog -> null
- char -> '\u0000'
- float -> 0.0f
- boolean -> true
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:
67 comments Page 2 of 7.
Jayesh said:
10 years ago
Is dog is which type of data type is it enumerated data type are users defined the data type?
(3)
Abhi said:
1 decade ago
Why option 2 is wrong?
(1)
Nisa said:
2 months ago
Any text written inside double quotes in Java is a String literal, which refers to a String object.
Am I right?
Am I right?
(1)
Indu said:
1 decade ago
Please explain the difference between the method overloading and method overriding?
(1)
Subhash said:
1 decade 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.
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)
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.
char default value \u0000 in c.
dog s a object so that default value null.
(1)
Dinesh saini said:
1 decade ago
why (3) is correct, as we don't know the data type of DOG so we can't say what will be the default that it may hold.
If DOG is any object then 'DOG -> null' will be ok but here we don't know anything about the word DOG so default value can't be assumed by words.
If DOG is any object then 'DOG -> null' will be ok but here we don't know anything about the word DOG so default value can't be assumed by words.
(1)
Senthil said:
1 decade ago
The string default value is null.
So, why option 2 is wrong?
So, why option 2 is wrong?
(1)
Sireesha said:
1 decade ago
What is that \u declared in char?
(1)
AVINASH said:
1 decade 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.
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)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers