Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

More arrays

 
Snylt Master
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody.
Can anyone please explain this.
Mockexam question:
Which of the following are legal array declaration. Select all correct answers.
A. int[5][]; // Correct
B. int[][]; // Not correct
C. int[]i[]; // Why is this correct?
D. int[5][5]; // Correct
E. int[][]a; // not correct
I'm just wondering why the "C" option is correct!
I have a question for the real exam to. I wonder if I can take a piece of paper and a pen into the examroom when I'm taking the exam. If I don't can anyone please help me how the best soulotion to problems like this should be solved
24 XOR 78
0XFFA & 45
Thanks


------------------
Preparing for the Java 2 Certification exam
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Snylt,
First off, this is a terrible question and one you will not see on the exam. An array declaration tells the compiler what the array's name is and what the type of its elements will be.
Using that definition we can easily say that:
A, B, and D are incorrect because no variable name is supplied.
We can also say that B and E are correct because they do supply both type and variable names.
The above can be tested out by compiling any class with choices A,B, and D. The class will not compile successfully.
If we place B or E inside a class it will compile without any errors.
IMO, you can bring in a scrap piece of paper but you must leave it behind when you leave the testing site.
Regards,
Manfred.
 
Snylt Master
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Manfred. This question was obviously porly written , and
with wrong answers!
Anyways... thanks you for sorting this out for me.

------------------
Preparing for the Java 2 Certification exam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic