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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:38:00+00:00 2026-05-29T06:38:00+00:00

As Super Class objects cannot be instantiated in the main function abstract keyword is

  • 0

As Super Class objects cannot be instantiated in the main function abstract keyword is specified before the class name.But what difference does it make if an abstract keyword is used before the SuperClass over-riding method or not used. Can someone explain it please?

Here is the below example.Please check the commented part.

abstract class Figure
{
    int dim1;
    int dim2;

    Figure()
    {
        dim1=-1;
        dim2=-1;
    }

    Figure(int p,int q)
    {
        dim1=p;
        dim2=q;
    }

    abstract void Area() //This line is working without abstract for me.
    {
        System.out.println("The area is undefined.");
    }
}

class Rectangle extends Figure
{
    int vol;
    Rectangle()
    {
        super();
    }

    Rectangle(int p,int q)
    {
        super(p,q);
    }

    void Area()
    {
        vol=dim1*dim2;
        System.out.println("The area of the rectangle is: "+vol);
    }
}

class Triangle extends Figure
{
    int vol;
    Triangle()
    {
        super();
    }

    Triangle(int p,int q)
    {
        super(p,q);
    }

    void Area()
    {
        vol=dim1*dim2/2;
        System.out.println("The area of the rectangle is: "+vol);
    }
}


public class Area 
{
    public static void main(String[] args) 
    {

        Rectangle r=new Rectangle(10,20);
        Triangle t=new Triangle(6,10);
        Figure fref;

        fref=r;
        r.Area();
        fref=t;
        t.Area();

    }

}
  • 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-29T06:38:01+00:00Added an answer on May 29, 2026 at 6:38 am
    abstract void Area();
    

    abstract means that it’s body will be defined in it’s derived class.

    if you try to define a body for it, it’ll be compiler time error.

    So, as a rule of thumb:

    An abstract class can have two kinds of methods: with body and without body. The methods with body cannot be prefixed with abstract keyword. However methods without body must be prefixed with abstract keyword.

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

Sidebar

Related Questions

If subclass in objective-c wants to override a super class's method, does it have
Why is object class the super class in Java?
Suppose the following object structure: class Super {} class SubA extends Super {} class
inheriting a class attribute from a super class and later changing the value for
Let's say I have a table that represents a super class, students . And
I was of the opinion that virtualization doesnt work in the super class constructor
I'm trying to invoke a method that takes a super class as a parameter
I want to rewrite core/adminthtml/block/widget/tabs.php class which is a super class for core/adminhtml/block/sales/order/view/tabs.php class.
I am getting this error: java.lang.ClassCastException: $Proxy0 cannot be cast to rmi.engine.Call at Main.main(Main.java:39)
This crashes: var grdMakes = Ext.extend(Ext.grid.Panel, { constructor: function(paConfig) { } } This does

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.