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 Q26 Exam Marcus03 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 "Q26 Exam Marcus03" Watch "Q26 Exam Marcus03" New topic

Q26 Exam Marcus03

Shiwani Aggarwal

Joined: Aug 21, 2003
Posts: 22
I think this is true -
The elements in a Java array can only be of primitive types, not objects. Why this is wrong?
Hanna Habashy
Ranch Hand

Joined: Aug 20, 2003
Posts: 532
arrays can hold objects and primitives. It depends on the decleration type
Object[] a = new Object[] //creats array of objects
int[] b = new int[] // creats array of integers
However, you can't assign a primitive type array to an Object type array.
b = a // compiler error
a = b // compiler error

and so on

SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Marcus Green
arch rival

Joined: Sep 14, 1999
Posts: 2813
If arrays could not hold Objects it would not be possible to create an array of Strings.

SCWCD: Online Course, 50,000+ words and 200+ questions
I agree. Here's the link:
subject: Q26 Exam Marcus03
jQuery in Action, 3rd edition