aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Query from Sun Sample questions. 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 "Query from Sun Sample questions." Watch "Query from Sun Sample questions." New topic
Author

Query from Sun Sample questions.

shyam ramineni
Ranch Hand

Joined: Jul 08, 2005
Posts: 43
Which three are legal array declarations? (Choose three.)

A int [42] x;
B int x [42];
C int [] x = (1,2,3);
D char [] myChars;
E int [] x = new int[] {2,4,5};
F int [] myScores [];

Answers given in the website are D,E,F.
Can anyone please tell me why C is not an answer.

Thanks
Shyam Ramineni


<a href="http://hyderabaditeducation.com" target="_blank" rel="nofollow">http://hyderabaditeducation.com</a>
Georgy Bolyuba
Ranch Hand

Joined: Feb 18, 2005
Posts: 162
C int [] x = (1,2,3);

Correct version:
C int [] x = {1,2,3};


SCJP 1.4 (100%) Done.<br />SCJD (URLyBird 1.2.3 Started)
Mani vannan
Ranch Hand

Joined: Aug 21, 2004
Posts: 185
int a[] = {1,2,3} is the correct syntax. {} should be used to enclose the constant list during initilization and '()' is not.


Manivannan
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
shyam, what message did you get when you attempted to compile and run code with option C in it?


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

Joined: Oct 14, 2002
Posts: 8815
    
    5
I'll let the folks at Sun know that the ePractice is causing some JR discussions


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Lalitha Vydyula
Ranch Hand

Joined: Jul 20, 2005
Posts: 69
Hi,
Can any one explain why the below declaration is legal.
int [] myScores [];

As far as I know arrays can be declared in two ways.

<element_type>[] <array_name>;

or

<element_type> <array_name>[];



-Lalitha
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
This is legal. It's called as array of arrays , a double dimentional array.


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Lalitha Vydyula
Ranch Hand

Joined: Jul 20, 2005
Posts: 69
Thanks Srini , it didn't click me that its a multidimensional array.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query from Sun Sample questions.