Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8055287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:20:21+00:00 2026-06-05T08:20:21+00:00

Why does this compile? (tried under both Oracle java 5 & java 6 (yes,

  • 0

Why does this compile? (tried under both Oracle java 5 & java 6 (yes, I know, I’m slow to adapt)

public abstract class BaseClass
{
    public abstract void methodA(String abc);

    public abstract String methodB(String abc);
}

public final class ConcreteClass
extends BaseClass
{
}

Just pop those two classes into separate files, call the javac on them and poof, they compile. Since abstract methods are intended to be implemented by implementors, this doesn’t make sense. Playing with this a bit further, I only receive a compile error when a chunk of code attempts to call the unimplemented method.

So again, my question here is, does anyone know WHY the compiler allows this (or why we would want it to do this)?

Additional comment:

  • When I did initial testing, I originally didn’t have the ConcreteClass marked as final, and it occurred to me that another class could extend the class and thus, the complier might not complain and assume that you would have some other class later on down the road take care of it, but marking the class as final should make it pretty clear that this is not the case.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:20:23+00:00Added an answer on June 5, 2026 at 8:20 am

    As @Jigar has mentioned in the comment, you must be importing wrong version of BaseClass. When I
    tried to compile your code, I get following error:

    /Users/ShirishP/Desktop/ConcreteClass.java:1: ConcreteClass is not abstract and does not override abstract method methodB(java.lang.String) in BaseClass
    public final class ConcreteClass extends BaseClass
                 ^
    1 error
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know why this doesn't compile? public class ArrayCompare{ public static void main
I just found my code like this does not compile right? Is there any
Why this code does not compile (Cygwin)? #include <vector> template <class Ttile> class Tilemap
In this statement, taken from the Pagerank source code: Pattern.compile(\\[.+?\\]); What does the pattern
I installed qt 4.7.4 and gcc 4.6.1. I tried to compile this program but
I tried annotating the enclosing method with @SuppressWarnings(compareIdentical) but this does not work (worse
I tried the code from this question C++ std::transform() and toupper() ..why does this
this compiles :-) string name; name = 1; this does not: string name =
This compiles: int* p1; const int* p2; p2 = p1; This does not: vector<int*>
std::string x(x); This crashes very badly on my compiler. Does this mean I should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.