File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes mock 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 "mock" Watch "mock" New topic
Author

mock

Shalini Srivastav
Ranch Hand

Joined: Jul 21, 2012
Posts: 86
I thought it wont compile as there is a JILL label which has no meaning.

I don't know how it is valid in mock question ?


[Thumbnail for untitled.JPG]

Gaurangkumar Khalasi
Ranch Hand

Joined: Jun 02, 2012
Posts: 186
Shalini Srivastav wrote:I thought it wont compile as there is a JILL label which has no meaning.

I don't know how it is valid in mock question ?


First of all, please UseAMeaningfulSubjectLine.

Label is always attached with a statement. So, when you are trying to use "uselesslabel:" a label without a statement, it will give you errors...
Shalini Srivastav
Ranch Hand

Joined: Jul 21, 2012
Posts: 86
You are not correct.
Gaurangkumar Khalasi
Ranch Hand

Joined: Jun 02, 2012
Posts: 186
Shalini Srivastav wrote:You are not correct.

You got an error??? Or What are you trying to say?
Shalini Srivastav
Ranch Hand

Joined: Jul 21, 2012
Posts: 86
I don't know what did you mean by statement.

Gaurangkumar Khalasi
Ranch Hand

Joined: Jun 02, 2012
Posts: 186
A statement in Java forms a complete command to be executed and can include one or more expressions.
or
A statement is a single "command" that is executed by the Java interpreter.

Different kinds of statements in java for example:
1). Declaration Statement (e.g. int value;)
2). Expression Statement (e.g. value=7;)
3). Control flow Statement (e.g. for(int i=0; i<10;i++) {} )
4). Null Statement (e.g. ; )
Kedar Pethe
Ranch Hand

Joined: Jul 17, 2012
Posts: 39
Shalini Srivastav wrote:I thought it wont compile as there is a JILL label which has no meaning.

I don't know how it is valid in mock question ?


Add a semicolon(;) at the end of uselsesslabel: (ie- uselsesslabel:;)

Just by luck it compiles without errors... could somebody explain this???
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

I am surprised how a topic which is not used at all in the Java world could ignite such a discussion. In OCPJP, labels are there only for the questions with labelled break. Application wise, labels are never used at all. This is a migration from C's jump statements.

Also Shalini, Gaurang's code is correct


This code runs and outputs the String inside the println.

The error is due to improper ending(without the semicolon) which actually makes the the closing bracket as a statement which is clearly an error and this is stated very specifically when you do a javac on the class file.


[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mock