Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: 1 class heir from 2 others?

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    11
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 1 class heir from 2 others?

    Hello i have 3 questions:
    1) Is it possible one class to heir from two other calasses?
    2)Is it possible a constructor exist without parameters?
    3)A constructor must return the class who construct?


  2. #2
    Member
    Join Date
    Jun 2012
    Location
    Left Coast, USA
    Posts
    451
    My Mood
    Mellow
    Thanks
    1
    Thanked 97 Times in 88 Posts

    Default Re: 1 class heir from 2 others?

    Quote Originally Posted by azizmaiden View Post
    1) Is it possible one class to heir from two other calasses?
    If you are asking about multiple inheritance (as found in, say, C++) the answer is no, and there are a number of reasons why multiple inheritance is not supported in Java

    Quote Originally Posted by azizmaiden View Post
    2)Is it possible a constructor exist without parameters?
    Aren't there any examples in your textbook or class notes or other material from which you are learning? Maybe even some explanations of what constructors are and what they do?

    Quote Originally Posted by azizmaiden View Post
    3)A constructor must return the class who construct?
    A constructor doesn't have a return data type and it doesn't return anything. Aren't there any examples in your textbook or class notes or other material from which you are learning? Maybe even some explanations of what constructors are and what they do?


    Cheers!

    Z

  3. The Following User Says Thank You to Zaphod_b For This Useful Post:

    azizmaiden (March 2nd, 2013)

  4. #3
    Junior Member
    Join Date
    Feb 2013
    Location
    Germany
    Posts
    27
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Re: 1 class heir from 2 others?

    Regadring the interface view of multiple iheritance, you could use two or more interfaces, it will work.

    Apart from that you can simulate multiple inheritance by declare and instaniate abstract classes in extending classes.

    But that's all not the c++ way, unfornately .Refering the link: it occurs more than one time, I wish I have the power of C++ when I use java. But for me java is the best language anyway. Mainly because everything is on the heap

    And to question 2:that's the standard constrcutor, every java class has it, except you declare another one

    question 3: it's like the 'new' in C++, it's a special method it can only return a class instance

  5. #4
    Junior Member
    Join Date
    Feb 2013
    Posts
    11
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: 1 class heir from 2 others?

    thank u very much for ur help yeah also i found the second one ;p u r very helpfull guys!

Similar Threads

  1. Java, calling another public class from within the main class giving problems.
    By RandomGaisha in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 26th, 2012, 02:30 PM
  2. Replies: 2
    Last Post: November 18th, 2012, 02:09 PM
  3. need to make basic class and implementation class (base class without void main)
    By javanewbie101 in forum Object Oriented Programming
    Replies: 1
    Last Post: September 19th, 2012, 08:03 PM
  4. create a test class (main method) to start(run) the class in Java
    By curious725 in forum Java Theory & Questions
    Replies: 5
    Last Post: August 1st, 2012, 03:21 AM
  5. Replies: 3
    Last Post: June 17th, 2012, 06:22 PM