aspose file tools*
The moose likes Mock Exam Errata and the fly likes Marcus exam 3 # 26 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "Marcus exam 3 # 26" Watch "Marcus exam 3 # 26" New topic
Author

Marcus exam 3 # 26

Stewart Henry
Greenhorn

Joined: Jun 01, 2001
Posts: 4
Question is:

The correct answer is given as 2. I don't believe that this is correct, because only elements within arrays are always initialized, the arrays themselves are not always initialized. For example this code:

gives the familiar compile error - Variable arr may not have been initialized.
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

Hi Stewart,
It gives compiler error because array has not been created.
Try this -
<pre>
int arr[] = new int[10];
System.out.println(arr);
System.out.println(arr[9]);
</pre>
This creates an array of 10 integers, and initializes all of them to 0. This compiles and prints correctly.
HTH,
- Manish
[This message has been edited by Manish Hatwalne (edited October 01, 2001).]
laxmikant shimpi
Greenhorn

Joined: Sep 18, 2001
Posts: 21
I think the difference is between creation and declaration ...
Arrays are used with these three steps.
1. Declare an Array
2. Construct an array
3. Use an array or a single array element..
now what you did in your code was just the declaration ....
and what Marcus says was creation ... perhaps it should be construction ....
may be the wording should be

2) Arrays are initialized to default values wherever they are created ( Constructed )
this should potentially reduce your chances of understand the answer...
I hope this works fine with you .....
Please reply any one with different opinion ...
Laxmikant


------------------

Sun Certified Java Programmer
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Declaring an array doesn't actually create an array. All it does is create a pointer that can hold an Array object. The array itself is created until a "new" is executed.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
I have just changed the text to the following, what do you think? I want my questions to be unambiguous as well as correct.
2) Arrays elements are initialized to default values wherever they are created with a call to new
------------------
http://www.jchq.net Mock Exams, FAQ, Tutorial, Links, Book reviews
=================================================
Almost as good as JavaRanch
=================================================


SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
Stewart Henry
Greenhorn

Joined: Jun 01, 2001
Posts: 4
Yes Marcus, I like that much better.
marilyn murphy
Ranch Hand

Joined: Aug 28, 2001
Posts: 84
How about
2) Arrays elements are initialized to default values wherever an array is created using the keyword new.
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
New wording, thanks for all the feedback.....
2) Arrays elements are initialized to default values wherever they are created using the keyword new.
------------------
http://www.jchq.net Mock Exams, FAQ, Tutorial, Links, Book reviews
=================================================
Almost as good as JavaRanch
=================================================
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

Originally posted by Marcus Green:
New wording, thanks for all the feedback.....
2) Arrays elements are initialized to default values wherever they are created using the keyword new.

It is ambiguous wether "they" referrs to "arrays" or "array's elements."
2) Array's elements are initialized to default values whenever arrays are created using the keyword new.
English, such a funny language...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Marcus exam 3 # 26