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 8734059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:46:11+00:00 2026-06-13T09:46:11+00:00

Here is the scenario:- class Canine{ public void roam(){ System.out.println(Canine-Roam); } } public interface

  • 0

Here is the scenario:-

class Canine{
  public void roam(){
    System.out.println("Canine-Roam");
  }
}

public interface Pet{    
  public abstract void roam();
}


class Dog extends Canine implements Pet{

  public void roam(){
    System.out.println("Dog Roam");
  }
  public static void main(String [] args){
    Dog adog = new Dog();
    adog.roam();
  }
}

I am aware that JVM must not have any confusion in choosing which method to run, that means, which method gets over-ridden. But I am confused anyway. Why does this program compile?

  • 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-13T09:46:12+00:00Added an answer on June 13, 2026 at 9:46 am

    No – the same method cannot exist in a class twice.

    An interface simply declares a requirement for a class to implement a particular method. It does not actually create that method.

    So a class that acquires a method implemention through inheritance has that method defined. This (single) implementation satisfies the interface’s requirements.

    In your case:

    1. Dog extends Canine, so it means that the roam() method from Canine is available, and would be exposed as a method on Dog objects if not overridden.
    2. But then Dog then overrides the superclass’ method with its own definition of roam(). This is allowed, and there is still just one unambiguous method called roam() on Dog – the new override.
    3. Dog implements Pet, which means it is required to have a roam() method. It does – so it’s a valid implementation of this interface.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the scenario i am faced with: public abstract class Record { } public
I have scenario like Here is the abstract class abstract class A { public
Here is the scenario public class Connection { public virtual void close() { /*Some
Here is a scenario class page { public $name; public $title; public function showhead()
Issue Seems like the condition gets ignored. Here is my scenario: Source class public
How do I do that? The scenario: abstract class DataAccess { public abstract string
i have this scenario: class MyClass { Producer p; Consumer c; public static void
Here is the scenario: I have: public class RandomStringUUID { public RandomStringUUID() { final
Here's the scenario: template <template <typename> class T, typename V> struct parent { void
Here's the scenario: I'd like to have a host class that can have a

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.