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:
64 comments Page 5 of 7.
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?
Saikrishna said:
1 decade ago
How Boolean is false only? Please explain.
Sunil said:
1 decade ago
Int-0.
Float-0.0.
Char-space.
Boolean-false.
Byte-0.
Short-0.
Long-0.
Double-0.0.
Float-0.0.
Char-space.
Boolean-false.
Byte-0.
Short-0.
Long-0.
Double-0.0.
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.
Prateek kumar baranwal said:
10 years ago
Dog data type is fully user define for class or data type.
Subhash said:
10 years ago
All other datatypes are predefined except Dog, which is meaningless in this question.
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.
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)
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.
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)
Anonymous said:
9 years ago
Dear Sundar.
It's a static String which not consist quotes. Dog.
It's a static String which not consist quotes. Dog.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers