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

The Archive Base Latest Questions

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

I am just trying myself to be comfortable with java api. But I am

  • 0

I am just trying myself to be comfortable with java api. But I am unable to do it. Not knowing the purpose of when to use abstract class.

Consider the java library collections

                          Collections

            List                                Set

All 3 are interfaces but the major thing , though they have functions which are common that is add , addAll, contains,containsAll etc. List implements in its own and set implements in another way ( telling about duplication ). Set does not allow duplicates list allows duplicates.

So what I am trying to say is when ever there is no common features for sub-entity with super-entity we have to go for interface

To still more make it clear , if suppose we make Collection as abstract class we need some methods to be properly defined rather than just declared but the functionality of list and set is differnt ( no common definition to bothe) hence they just declared it as interface and made a force rule that both list and set should implement this.

But if there is some common functionality which both has then keep it as to be abstract class.

So to get an example from Java itself. Lets consider Number class which is made ABSTRACT. Lets see why it could not be done using interface now!!!

**public abstract class Number
extends Object
methods are**

byte byteValue()
Returns the value of the specified number as a byte.

abstract double doubleValue()
Returns the value of the specified number as a double.

abstract float floatValue()
Returns the value of the specified number as a float.

abstract int intValue()
Returns the value of the specified number as an int.

abstract long longValue()
Returns the value of the specified number as a long.

short shortValue()
Returns the value of the specified number as a short.

Now here the byteValue is a non-abstract method and other methods XXXValue are abstract. We will see Y???

byteValue()

// taken from Number class java doc api

public byte byteValue()

Returns the value of the specified number as a byte. This may involve rounding or truncation.

And this byteValue() method is being overriden by all the other classes like Integer,Double,Float etc.

Instead they can keep byteValue() also abstract !!! But they dint do it. Wish to know why they have done like this.

  • 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:03:27+00:00Added an answer on June 4, 2026 at 4:03 am

    byteValue() is not overridden in all the Number subclasses. For example, it’s not in BigInteger, AtomicInteger, AtomicLong, BigDecimal. All those classes benefit from the default implementation in the Number class.

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

Sidebar

Related Questions

Just a warning: I'm completely new to Java and am trying to teach myself
I'm just trying to teach myself how to use Linq. This is what I
I'm trying to teach myself SOAP, just to extend my skillset a bit, but
just trying to test for equality in this piece of code, but getting a
This may seem obvious to most people, but I'm just trying to confirm that
I am just trying to familiarise myself with the basics of C++ moving from
I don't consider myself a Mac power user but permission in particular are confusing
I am trying to teach myself how to use SQL, namely mysql. What I
I'm struggling trying to teach myself Mockito. Consider the following method, hasInventory() , which
I am playing about just now trying to teach myself a little bit about

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.