• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

array

 
thrilok nath
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to create arrays of length zero?
Select the one correct answer.
a.Yes, you can create arrays of any type with length zero.
b.Yes, but only for primitive data types.
c.Yes, but only for arrays of object references.
d.No, you cannot create zero-length arrays, but the main() method may be passed a zero-length array of String references when no program arguments are specified.
e.No, it is not possible to create arrays of length zero in Java.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

The best way to learn (especially when preparing for the SCJP exam) is to write lots of test code. Have you tried to create primitive/object arrays of length zero and verify their length?
 
Anup Jadhav
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well said, Marc !

Thrilok, I've tried out this and the correct answer is 'a'.
You can create an array of any type, of length 0.

Anup
 
Jianghu Li
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A is correct!

Output is:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic