• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
Bartenders:
  • Himai Minh
  • Carey Brown
  • Frits Walraven

How to understand this statment

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question about this statment (extract from Dan Mock Exam -- Chapter 3 Exam 2:
Q13
(Object[])a.clone();
How to understand this statment?
Is it equal as ((Object[])a).clone() or (Object[])(a.clone()) ?
According to the question, I think it is equal as (Object[])(a.clone()). Can anyone tell me how to get the rules of the similar statment?

Thanks advance
Ming Yang
--------------------
Ming Yang
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Postfix operators (like .) has higher precedence then cast operators.
Section 3.1 of Khalid Mughal book may help !
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yang,
I have to run out the door right now so I unfortunately can not answer this one right now. However, I will suggest that you post the entire questions so that people have a better understanding of the context. Another option might be to post a link to the exam.
I'm sure that a lot of people on this message board can answer that question if they have all of the information.
Of course, anyone can now use the URL in my signature.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The entire question is as follows.

A two dimensional array is really an array where each element is another array. A two dimensional array is therefore an array of objects. It is therefore legal to clone an array and cast the returned object to an array of objects.
Each element of the array, obj, is an array of primitive int values. Each element of obj can therefore be cast to int[].
This question is intended to demonstrate that a multidimension array is just an array that contains other arrays.
The correct answer is g. The output is 112.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic