Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Abstract class  RSS feed

 
gurpreetsingh hora
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class A
{
}

abstract class B extends A
{
}
if yes why??
if no why??
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please be a bit specific on what you need?
 
Amir Alagic
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please explain what you want to know... I�m not sure what you wanted to ask but if you wanted to know if it compiles then answer is yes...
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes your abstarct class can extend the a full-qulified class. there is nothing wrong in your code.
 
Paul Clapham
Sheriff
Posts: 22472
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice that every abstract class ultimately extends Object, which is not abstract. That should explain all parts of your question, if you think about it for a bit.
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


Notice that every abstract class ultimately extends Object, which is not abstract. That should explain all parts of your question, if you think about it for a bit.


Thats a perfect answer for your piece of question.
 
Sidd Kulk
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably he wants to know why should an abstract class be allowed to extend a non-abstract class. Its because a concrete type may have abstract subtypes, for example, a concrete class Car, with full functionalities of driving a Car, can have abstract subtypes of Diesel driven Car or Petrol driven Car, or a CNG driven Car.

Sid
 
gurpreetsingh hora
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sidd Kulk:
Probably he wants to know why should an abstract class be allowed to extend a non-abstract class. Its because a concrete type may have abstract subtypes, for example, a concrete class Car, with full functionalities of driving a Car, can have abstract subtypes of Diesel driven Car or Petrol driven Car, or a CNG driven Car.

Sid


Thanks everybody and especislly to Mr.sidd
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!