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

Hema said:   1 decade ago
Please can anyone explain hexadecimal representation?

Thiru said:   1 decade ago
char in Java is an unsigned 16 bit numerical value representing a two-byte Unicode character.

Since you left it as default, your char is 0, or u\0000. This is the Unicode NULL value.

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

Dagg said:   1 decade ago
Can someone describe: System.out.println();?

Pooja said:   1 decade ago
System-is class of java.lang package.
Out-is static final method of System class. So it is called directly with class name.
(System.out).

And out is also reference of PrintStream class.
println-is method of PrintStream class in java.io package.

So it is called with reference of that class.
(System.out.println).

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?

Rajat said:   1 decade ago
Can somebody explain me how dog variable is initialize to null? In netbeans compile is showing an error. As dog variable is not initialized.

Satya said:   1 decade ago
Can any one explain double default value in Java?

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.

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.