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 Abstract methods don't have a body- confused 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 "Abstract methods don Watch "Abstract methods don New topic
Author

Abstract methods don't have a body- confused

Xyz Abc
Greenhorn

Joined: Aug 24, 2007
Posts: 27
Hi, abstract methods don't have a body and should end in a semicolon when described in an abstract class, but one big doubt.

What happens if you do declare it this way?

public void jump();

I tried it and there is NO COMPILER ERROR

Also, if I try marking a method as abstract and don't mark the class as abstract there is no compiler error again. My program runs fine.

Am I doing something wrong???
Please help!!

Thanks,
Nicole.
Xyz Abc
Greenhorn

Joined: Aug 24, 2007
Posts: 27
please help!!!
palla sridhar
Ranch Hand

Joined: Oct 15, 2007
Posts: 111
Hi Nicole!!
I checked your doubt on my Java platform. I think you're doing something wrong or missing something, because when you declare like this,
public void jump();
in a normal or abstract class, you're BOUND to get a COMPILER ERROR like this:


Also if you don't declare a class abstract having a abstract method you get a COMPILER ERROR like this:

Check it out once again!!


Thanks and Regards,
[url]www.techlikes.com[/url]
*Nothing is CONSTANT in life, except CHANGE*
Xyz Abc
Greenhorn

Joined: Aug 24, 2007
Posts: 27
You know the weirdest thing is, its still compiles fine
Yogesh Baraskar
Ranch Hand

Joined: Oct 07, 2007
Posts: 33
Hi

Plese send the complete source code which you are trying to compile
palla sridhar
Ranch Hand

Joined: Oct 15, 2007
Posts: 111
Hi Nicole!!
Try compiling both these classes.
Eg1:


Eg2:


If this is what you mean, then can you check whether these COMPILE??
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1558
Originally posted by Nicole Facompre:
You know the weirdest thing is, its still compiles fine


Please copy paste the code here...


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Rahul Shilpakar
Ranch Hand

Joined: Aug 29, 2006
Posts: 132
hi palla,

both example that you gave won't compile..

so it should be like this only ..

Ex1.
public abstract class A{

public abstract void method1();
}

OR

public abstract class A{

public void method1(){
}
}


Perform for today. Adapt for tomorrow.
Rahul Shilpakar
Ranch Hand

Joined: Aug 29, 2006
Posts: 132
hi palla,

both example that you gave won't compile..

so it should be like this only ..

Ex1.
public abstract class A{

public abstract void method1();
}

OR

public abstract class A{

public void method1(){
}
}
Rahul Shilpakar
Ranch Hand

Joined: Aug 29, 2006
Posts: 132
hi palla,

both example that you gave won't compile..

so it should be like this only ..

Ex1.
public abstract class A{

public abstract void method1();
}

OR

public abstract class A{

public void method1(){
}
}
Xyz Abc
Greenhorn

Joined: Aug 24, 2007
Posts: 27
I actually figured out what is wrong with my Eclipse. It shows the error happening in the Problems tab but also compiles and prints something to the console. Is this a problem with my compiler?
Doug Slattery
Ranch Hand

Joined: Sep 15, 2007
Posts: 294
Hi Nicole,

When you ran the program, did you get a dialog that said:

"Errors exist in required project(s):"
...
"Proceed with Launch?"

This means that there is a problem in your code, but Eclipse will try to run it anyway. Sometimes, it *will* run, but can be misleading (obviously).

Aloha,
Doug

-- Nothing is impossible if I'mPossible
Xyz Abc
Greenhorn

Joined: Aug 24, 2007
Posts: 27
I think I have suppressed the option to show that dialog box sometime back

Anyway I know now!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract methods don't have a body- confused