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:
67 comments Page 5 of 7.

Piyush gadekar said:   2 decades ago
What your are tryng to admit from this program?

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

Sundar said:   2 decades ago
@Shaswati

It is nothing but a class created by a user.

Ex: Dog, Student, Car etc.

The question is 'what will be default value?'.


Student objStud1;

Here objStud1 will contain 'null' value by default.

Prathyusha said:   2 decades ago
HI,
No where the "Dog" datatype is mentioned.
If Dog is integer , the default might be -0
If Dog is float , the default might be -0.0f
If Dog is object ,the default might be -null
.... No where it is mentioned whether Dog is wat datatype.
HELP ME IN THIS REGARD.....

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

Suresh said:   2 decades ago
Nice answers

Kathirozhi said:   1 decade ago
Plese correctly tell the char default value is nothing or not null or the answer in the question please help to understand.

Rehana said:   1 decade ago
What is that \u declared in char?

Sivachandran said:   1 decade ago
@Kathirozhi not null and nothing nice answers.

Amarjeetkaur said:   1 decade ago
Please tell me anyone, what is the history of java ? In briefly words.


Post your comments here:

Your comments will be displayed after verification.