File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
*
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
Author

Q26 Exam Marcus03

Shiwani Aggarwal
Greenhorn

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
hi:
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
Rancher

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
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Q26 Exam Marcus03