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

  • SEARCH
  • Home
  • 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 7023817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:45:33+00:00 2026-05-27T23:45:33+00:00

Let’s consider the following simple code in Java. package temppkg; interface Interface { @Override

  • 0

Let’s consider the following simple code in Java.

package temppkg;

interface Interface
{
    @Override
    public abstract boolean equals(java.lang.Object arg);

    @Override
    public abstract String toString();

    public void show();
}

final class Demo implements Interface
{
    public void show()
    {
        System.out.println("Method invoked.");
    }
}

final public class Main
{
    public static void main(String...args)
    {
        new Demo().show();
    }
}

In the above code snippet, the interface named Interface has some Object class methods from JDK and they are with the @Override annotation even though they are abstract. Now, the class Demo has implemented Interface and has not implemented the equals() and the toString(); methods. Still the compiler doesn’t complain and the program is running successfully. Why?
What is the relation between interfaces and the object class in Java?

  • 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-05-27T23:45:34+00:00Added an answer on May 27, 2026 at 11:45 pm

    The Java Language Specification clearly says that the members of an
    interface are those which are declared in the interface and those
    which are inherited from direct super interfaces. If an interface has
    no direct superinterface then the interface implicitly declares a
    public abstract member method corresponding to each public instance
    method declared in the Object class, unless a method with the same
    signature, same return type, and a compatible throws clause is
    explicitly declared by that interface. This is what makes the
    signatures of the Object methods available to the compiler and the
    code compiles without any error. Remember if the interface tries to
    declare a public instance method declared ‘final’ in the Object class
    then it’ll result into a compile-time error. For example, ‘public
    final Class getClass()’ is a public instance method declared ‘final’
    in the Object class and therefore if an interface tries to declare a
    method with this signature then the compilation will fail.

    http://geekexplains.blogspot.com/2008/06/do-interfaces-really-inherit-from-class.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's consider the following scenario: I've a master table with a detail table. The
Let's imagine I have a Java class of the type: public class MyClass {
Let's say I have the following entity: public class Store { public List<Product> Products
Let's consider a simple grid, where any point is connected with at most 4
Let's say I have following POJO's using Hibernate. public class User { private String
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers>
Let say I have some code HTML code: <ul> <li> <h1>Title 1</h1> <p>Text 1</p>
Let's suppose I have this piece of code. foreach(string value in myList) { string
let's say I have the following string: string s = A B C D

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.