• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Fill-in the black questions help!!

 
natarajan meghanathan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can you please clarify whether we should semicolon at the end of the statement or not!!.
I was taking a JQ+ exam and one question was creating a layout manager. I am sure i wrote fine. It is
LayoutManager layout = new GridLayout(1,2);
But it gave me an error. The explanation they give was like how to create a layout what it does and all. But i think i got it wrong because of the semi-colon.
TIA.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the REAL exam you will need the semi-colon.
 
a vinay
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you got the error because LayoutManager is an interface.We can only assign reference to it.We cannot use new operator with the interface i.e. they cannot be instantiated.
vinay
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Vinay,
natarajan is correct. He's not new-ing an interface. He is using an interface reference to a GridLayout object which is allowed.
Cindy is correct. You will need to add a semicolon on the real test.
I asked SUN this question, and they said you should type it as though you were programming. From your statement, it looks correct. If you left off the semicolon, the statement would not have compiled.
-Peter
Ps. A Vinay, please see our naming policy at JavaRanch and re-register. Unless you really have people calling you "A", it would be appreciated if you would register with a complete first name. This way, if we ever run into each other, I don't have to feel bad shouting, "A...A!" (It makes me feel like I'm going through rehab.)
 
Michael Burke
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I gave the same answer to that question from JQ+ but one of the possible correct answers was the answer we gave so I quess it's just a mistake on JQ+ end.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic