• 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
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Array declaration question on K&B OCA Exam1 CD

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving my question to the correct forum -


Hi,

I am going through the OCA Exam from the CD included with Kathy and Bates's OCA / OCP Java SE 7 Study guide.





This question has me confused - A is one of the valid answers but I believe option B is valid too, apparently it isnt. I am unable to figure out why! (I think its probably something very simple that I am unable to see - maybe its not a curly brace?).

Thanks in advance!
Harsha


 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harsha Pherwani wrote:This question has me confused - A is one of the valid answers but I believe option B is valid too, apparently it isnt. I am unable to figure out why! (I think its probably something very simple that I am unable to see - maybe its not a curly brace?).


You are correct about the code snippet you have posted: both array declarations and initializations will declare an array and initialize it with four members. But your option B is different from the option B in the K&B7 OCA Exam 1 question. So if you look very carefully to this option, you'll notice that option B looks likeIf you want to use the shortcut syntax to create and initialize an array, you'll must use curly braces ({}) and not parantheses (()) because that would result in a compiler error. And that's why option B is not a correct answer!

Hope it helps!
Kind regards,
Roel
 
Harsha Pherwani
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah I thought it was something like that, but I just couldn't see the round brace, it seemed like a curly brace to me!

thanks!
Harsha
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harsha Pherwani wrote:Ah I thought it was something like that, but I just couldn't see the round brace, it seemed like a curly brace to me!


Please note you need a great eye for detail on the actual exam, because you could expect to encounter similar questions on the actual exam
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic