About Question com.enthuware.ets.scjp.v6.2.690 :

Moderator: admin

Post Reply
jivraj
Posts: 5
Joined: Sun Jul 24, 2011 12:01 pm
Contact:

About Question com.enthuware.ets.scjp.v6.2.690 :

Post by jivraj » Mon Aug 15, 2011 4:44 am

abstract class Automobile
{
void honk(){};
}

Why is there a semicolon at the end of the method honk?

admin
Site Admin
Posts: 8297
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.690 :

Post by admin » Mon Aug 15, 2011 10:18 am

It is an empty statement. It is not required but it is not wrong either.
If you like our products and services, please help us by posting your review here.

jivraj
Posts: 5
Joined: Sun Jul 24, 2011 12:01 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.690 :

Post by jivraj » Mon Aug 15, 2011 10:30 am

Thanks for the reply...but I am not asking regarding the empty parenthesis but the semicolon which actually isnt required at the end. Also JCreator shows the following compiling error.

Automobile.java:3: missing method body, or declare abstract
void honk();
^
1 error

admin
Site Admin
Posts: 8297
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.690 :

Post by admin » Tue Aug 16, 2011 6:26 am

Yes, I am also talking about ; Addition semicolons are not required but they are not wrong. Please use regular Java compiler for OCPJP purpose.

The error message that you have quoted is because there is no method body i.e. { }. It is not because of semicolon.
If you like our products and services, please help us by posting your review here.

jivraj
Posts: 5
Joined: Sun Jul 24, 2011 12:01 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.690 :

Post by jivraj » Thu Apr 24, 2014 12:20 am

Thanks admin for the clarification :)

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 7 guests