Results 1 to 2 of 2
  1. #1
    achiu17 is offline Member
    Join Date
    Nov 2011
    Posts
    4
    Rep Power
    0

    Default Superclass and Subclass Constructor Question

    Java Code:
    public class bus {
       public bus(int number)
       { 
             passengers = number;
        }
        public bus ()
        {
                passengers = 0;
         }
    
    }
    
    public  class student extends bus {
    
       public student(double money){
          lunch = money;
    }
    
    }
    Which constructor(s) is called for student and explain why?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Superclass and Subclass Constructor Question

    Let's see:
    -- Class names beginning with a lowercase letter
    -- Inappropriate inheritance
    -- Question unrelated to the code posted

    Rather than seek a nonexistent answer to one rather silly question, go through a good tutorial or book where you can actually learn Java.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Array of Objects (Superclass containing Subclass)
    By stupidwaldo in forum New To Java
    Replies: 47
    Last Post: 12-12-2011, 02:29 PM
  2. Override a superclass's methods with a subclass
    By zach&kody in forum New To Java
    Replies: 7
    Last Post: 05-24-2011, 03:50 PM
  3. Using superclass fields in subclass method
    By lonegreyride in forum New To Java
    Replies: 12
    Last Post: 11-17-2010, 02:21 PM
  4. superclass and subclass
    By mr idiot in forum New To Java
    Replies: 19
    Last Post: 01-03-2009, 08:29 AM
  5. which class is superclass and subclass?
    By java_fun2007 in forum New To Java
    Replies: 0
    Last Post: 12-11-2007, 09:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •