Page 1 of 1

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

Posted: Mon Aug 15, 2011 4:44 am
by jivraj
abstract class Automobile
{
void honk(){};
}

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

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

Posted: Mon Aug 15, 2011 10:18 am
by admin
It is an empty statement. It is not required but it is not wrong either.

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

Posted: Mon Aug 15, 2011 10:30 am
by jivraj
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

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

Posted: Tue Aug 16, 2011 6:26 am
by admin
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.

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

Posted: Thu Apr 24, 2014 12:20 am
by jivraj
Thanks admin for the clarification :)