• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

basic doubt

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
object is the base class for all classes. According to java there is no multiple inheriance.so we can extend only one class. Already object is the base class. if i extending one class means, is it multiple inheritance or not. if you need more information,let me know
------------------
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java uses only single inheritance. This means that each class can have only one direct "parent" class. It doesn't prevent a class also having a "grandparent" class, or several classes sharing the same "parent" class. As an example consider the following class structure from the java.io package:
class Object the base ancestor class, has no "parents"
class Reader extends Object has Object as "parent"
class BufferedReader extends Reader has Reader as "parent", Object as "grandparent"
class InputStreamReader extends Reader also has Reader as "parent", Object as "grandparent"
class FileReader extends InputStreamReader and so on...
As I hope you can see, even limiting each class to a single "parent" class still allows for a complex and useful inheritance structure.
Multiple Inheritance (not supported in Java) is a technique where each class can have more than one direct "parent". Most of the benefits of this approach are available in Java by using interfaces and the "implements" keyword.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic