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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:13:20+00:00 2026-06-04T04:13:20+00:00

So I was studying Abstract class in java, and when I was reading other

  • 0

So I was studying Abstract class in java, and when I was reading other people’s codes I saw the following:

public abstract class Message implements Serializable, Comparable<Message> {
    //stuff in this class
}

In another class under the same project, the programmer declared a method as follows:

public void notifyMessage(Message msg, HostType sourceType) {
    //some stuff in this method
}

Notice in the notifyMessage declaration, variable msg is of type “Message”. I thought all abstract classes cannot be instantiated? Then what does it mean to declare “Message msg”? Can someone explain what this means to me? Thanks in advance

  • 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-04T04:13:21+00:00Added an answer on June 4, 2026 at 4:13 am

    Well that means that you can receive any object of type Message (children), let’s put it in other way, if you have

    public class Letter extends Message ...
    

    you can send a Letter object as an argument for the notifyMessage

    Something like this could be possible:

    someObject.notifyMessage(  new Letter() , ... )
    

    java.awt.Component is abstract
    JPanel inherits Container (actually JComponent first)
    Container have add(Component c)

    That means that you can add any Component like JButton, JLabel, etc.

    http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Container.html#add(java.awt.Component)
    http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Component.html

    You can also make objects of Abstract classes if you define abstract methods and body of that object.

        Message m = new Message() {
            //if no abstract method, then this is empty
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm studying Java Concurrency in Practice and there it is explained why the following
I am now studying a java and I'm at the part of Abstract. I
when studying RMI sometimes (head first Java) dudes use Naming.rebind(name, object) but other peoples
I am Studying PHP and i was thinking, Methods inside Abstract Class or Interface
In studying actionscript 3's graphics class, I've come across the undocumented drawRoundRectComplex() method. It's
While studying for the Zend PHP Exam I came across the following contradicting information:
In studying for the OCP Java Programmer Exam, I was slightly surprised to see
While studying Java tutorials, Reflection and Late Binding have confused me. In some tutorials,
I was studying an open source code where I came across the following line
I am studying an existing Perl program, which includes the following line of code:

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.