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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:22:16+00:00 2026-06-15T10:22:16+00:00

How to call? How to do? public class Test { public static void main(String[]

  • 0

How to call? How to do?

public class Test {
        public static void main(String[] args) {
            Test test = new Test();
            Animal a = new Animal("Animal");
            Dog d = new Dog(" BigDog ","yellow");
            Cat c = new Cat(" SmallCat ","black");
            test.f(a); test.f(d); test.f(c); //(1)
        }

        public void f(Animal a) {
            System.out.println("name :"+ a.name);

            if(a instanceof Dog) {
                Dog dog = (Dog)a;
                System.out.println("    "+ fursColor + "fur"); //!(2)!Error
            }
            else if(a instanceof Cat) {
                Cat cat = (Cat)a;
                System.out.println("  " + eyesColor + "eye"); //(3)!Error
            }
        }
    }

Ask Question:

(1) What’s the meaning of this?

(2) How to call “yellow”?

(3) How to call “black”?

  • 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-15T10:22:16+00:00Added an answer on June 15, 2026 at 10:22 am

    (1) What’s the meaning of this?

    The method f is using instanceof as it is not use polymorphic methods to select the right type.

    Can you be more specific as to what you don’t understand.

    (2) How to call “yellow”?

    I assume you want is to retrieve the String in the field in dog with dog.fieldNameNotShownInYourExample as it did in a.name to get the name.

    (3) How to call “balck “?

    I assume it should be "black" but its the same as 2)

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

Sidebar

Related Questions

Suppose I have the following classes: public class Test { public static void main(String[]
Program.cs class Program { public static void He(string v) { Console.WriteLine(v); Console.WriteLine(End?); } public
I keep getting this error when I try to call Find() public void findTxt(string
I have this test [Test] public void SaveInventoryItemLoad_Will_Call_WCF_Service_SaveInventoryItemLoad() { adapter.SaveInventoryItemLoad(new List<InventoryItemLoadProxy>()); itemMasterBusinessClientMock.Verify(x => x.SaveInventoryItemLoad(It.IsAny<List<InventoryItemLoadProxy>>()),
I have a class defined like so: public class Test { static <T> List<Class<T>>
public class A { public void test(Integer i) { System.out.println(In Wrapper Method); } public
I've the following classes KeyValue.java package test; public class KeyValue<T> { private String key;
1 class test { 2 public static int compare0(Comparable x, Comparable y) { 3
Given the following Java code: public class Test { static private class MyThread extends
I just call glEnableClientState() once in onSurfaceCreated() method of GLSurfaceView.Renderer interface. Eg: public class

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.