• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

can a default class be subclassed?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

can a default class be subclassed?
please reply

Thanks in Advance
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi miria,

Ofcourse, The class with default acess is visible to all classes within the same package. so the default class can be subclassed(extend another class).



Here the class Test with defaul acess extends the class Test1.
output : This is Test1 class

Is this you are expecting...?
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you mean a class that isn't public by saying it's default.

Yes you can subclass it. You can even put the default and its subclass in the same file if you like (remember you can have multiple classes in a file but only one top-level class can be public). At the very least the subclass must be in the same package though, because of visibility.

You can even make the subclass public if you like. It wouldn't be likely you'd ever want to do this but you could.
 
miria joseph
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!!!
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear "miria",

I am one of the moderators of the JavaRanch forums. Here on JavaRanch, we have a naming policy. We want the users of JavaRanch to use a real-sounding name as their display name.

Unfortunately, your name "miria" does not comply to the naming policy. Your display name should consist of a real-sounding first name, space, and a second name. Not only a first name, no obviously fake nickname, no initials only for the second name.

Please read the naming policy carefully and change your display name. You can change your name by editing your profile.

Please note that we are taking the naming policy seriously. If you do not change your display name, your account on JavaRanch might be locked.

Have fun on JavaRanch,
Jesper Young - Bartender
 
Die Fledermaus does not fear such a tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic