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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:58:09+00:00 2026-05-27T19:58:09+00:00

I saw a class AttributeSelectedClassifier was once created in the following ways: AttributeSelectedClassifier classifier

  • 0

I saw a class “AttributeSelectedClassifier” was once created in the following ways:

AttributeSelectedClassifier classifier = new AttributeSelectedClassifier();

classifier.setClassifier(base);
classifier.setEvaluator(eval);

This above one looks natural to me. But how about the following one.

classifier = new AttributeSelectedClassifier();
((AttributeSelectedClassifier)classifier).setClassifier(base);
((AttributeSelectedClassifier)classifier).setEvaluator(eval);

I think it should be right, but I am not quite sure about the way of of defining classifier as ((AttributeSelectedClassifier)classifier), how to understand this usage?

  • 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-27T19:58:10+00:00Added an answer on May 27, 2026 at 7:58 pm

    Look at the below code. Person implements the CanWalk interface. If you assign a Person to CanWalk interface as shown in the main method, which is a common practice, you can only invoke the methods that are specified in the CanWalk interface i.e. walk(). If you want to invoke f(), that isn’t declared in the CanWalk interface, then you would use the 2nd mechanism you have specified in your post. i.e. cast it to Person class and then invoke the method.

    It is a good practice for the user’s of the API (main method here) to use the correct abstraction while working with an object. For e.g. if the client is mainly focused on moving Person’s then it should use CanWalk. This way client is not effected by changes to the Person class that are not related to movement. Read this article for more details.

    interface CanWalk
    {
      void walk();
    }
    
    class Person implements CanWalk
    {
      void walk()
      {
         System.out.println("I am walking");
      }
    
      void f()
      {
        ///some arbitrary method
      }
    }
    
    public stativ void main(String a[])
    {
       CanWalk cw=new Person();
       ((Person)cw).f();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] I saw this attribute in the reflector for the base class libraries
I saw this signature on the ListView class: public ListView..::.ListViewItemCollection Items { get; }
I saw this kind of code at work: class FooPlugin : IPlugin // IPlugin
I just saw code similar to this: public class Scratch { public static void
Recently I saw the following code that creates a class in javascript: var Model.Foo
I saw this question: If a "Utilities" class is evil, where do I put
Saw this line in a class method and my first reaction was to ridicule
I saw the Qt source code like this: class Q_CORE_EXPORT QBasicAtomicInt { public: ...
I saw the following snippet code: class Foo { public: void virtual func() throw
I was reading through this: http://www.postgresql.org/about/ And I saw this: An enterprise class database,

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.