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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:37:42+00:00 2026-06-05T19:37:42+00:00

A simple upcasting is going on where the sub calss(dog)’s object is referenced by

  • 0

A simple upcasting is going on where the sub calss(dog)’s object is referenced by its super class(Animal)…

Why i am not able to call the method ‘callme2()’

CODE:-

class Animal 
    { 
        public void callme()
        {
            System.out.println("In callme of Animal");
        }

    }

    class Dog extends Animal 
    { 
        public void callme()
        {
            System.out.println("In callme of Dog");
        }

        public void callme2()
        {
            System.out.println("In callme2 of Dog");
        }
    }

    class upcasting
    {
        public static void main (String [] args) throws Exception
        {
            Animal a = new Dog();     
    a.callme(); //-In call me of Dog       
    a.callme2(); // - error why ?
     }
    }
  • 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-05T19:37:44+00:00Added an answer on June 5, 2026 at 7:37 pm

    Because a is assigned to superclass Animal

    You can call the methed as follow:

    ((Dog)a).callme2() 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am rolling my own simple web-based perfmon, I am not happy with some
I'm not going to go into detail on the media player part except the
I'm writing a simple app that's going to have a tiny form sitting in
The steps are as simple as that so I imagine there's something else going
I have a simple test class: public partial class TEST_CLASS { public string IP
I am creating a simple application in JSP- JDBC for inserting and updating details
Simple question, but answer might be harder. I can't work out the effect on
Simple question, but I can't quite seem to figure it out: If i have
Simple question about regexps. I've got String text = foobar1foobar1; And I need to
Simple question, When i use fread: fread(ArrayA, sizeof(Reg), sizeBlock, fp); My file pointer, fp

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.