File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "array" Watch "array" New topic


thrilok nath

Joined: Aug 09, 2007
Posts: 1
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

Joined: Aug 31, 2004
Posts: 11343

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?

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Anup Jadhav

Joined: Jun 09, 2007
Posts: 9
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.


I code therefore I am.
Jianghu Li

Joined: Sep 01, 2007
Posts: 13
A is correct!

Output is:
I agree. Here's the link:
subject: array
It's not a secret anymore!