Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

arrays  RSS feed

 
velan vel
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai
can any one give ans for this question

1. byte [] arry1, array2[];
2. byte array3 [][];
3. byte[][] array4;
If each array has been initialized, which statement will cause a compiler error?
A. Array2 = array1;
B. Array2 = array3;
C. Array2 = array4;
D. Both A and B
E. Both A and C
F. Both B and C

by
velan vel
 
premraj cheguri
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the answer is A
 
santosh kothapalli
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
array2 is two dimensional array and cannot be referenced with one dimensional array array1 so the option is A
 
chennur gudur
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the answer is F
 
Suiram Namuen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But what makes array2 a two-dimentional array? I don't understand the syntax.
 
Sandeep Prabhakar
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the statement
"byte [] arry1, array2[];"
This is same as
byte[] arry1;
byte[] array2[];

Since the first "[]" is associated with the datatype (byte in this case), it is applicable to all the identifiers that follows (of course they should be comma seperated).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!