[JAVA100 example]006, inheritance of classes

Source: Internet
Author: User

Class Tree


{


/**


*<br> Method Description: Tree root


*<br> input Parameters:


*<br> return type:


*/


public void root ()


  {


String ssite = "soil";


String sfunction = "absorbent feed";


print ("Position:" +ssite);


Print ("function:" +sfunction);


  }


/**


*<br> Method Description: Tree trunk


*<br> input Parameters:


*<br> return type:


*/


public void Bolo ()


  {


String ssite = "ground";


String sfunction = "Pass The Feed";


print ("Position:" +ssite);


Print ("function:" +sfunction);


  }


/**


*<br> Method Description: Tree branches


*<br> input Parameters:


*<br> return type:


*/


public void Branch ()


{


String ssite = "on the trunk";


String sfunction = "Pass The Feed";


print ("Position:" +ssite);


Print ("function:" +sfunction);


  }


/**


*<br> Method Description: The leaves of the tree


*<br> input Parameters:


*<br> return type:


*/


public void leaf ()


  {


String ssite = "treetop";


String sfunction = "photosynthesis";


String scolor = "green";


print ("Position:" +ssite);


Print ("function:" +sfunction);


print ("color:" +scolor);


  }


/**


*<br> Method Description: Display information


*<br> input parameter: information displayed by Object Opara


*<br> return type:


*/


public void print (Object Opara)


  {


System.out.println (Opara);


  }


/**


*<br> Method Description: Main method


*<br> input Parameters:


*<br> return type:


*/


public static void Main (string[] arges)


  {


Tree T = new tree ();


T.print ("Describe a tree:");


t.print ("root:");


T.root ();


t.print ("trunk:");


T.bolo ();


t.print ("branch:");


T.branch ();


t.print ("leaf:");


t.leaf ();


  }


}


/**


* <p>title: Willow parameters </p>


* <p>description: Description of willow parameters </p>


* <p>copyright:copyright (c) 2003</p>


* <p>filename: </p>


* @author Dujiang


* @version 1.0


*/


class Osier extends tree


{


/**


*<br> Method Description: Overload tree leaves


*<br> input Parameters:


*<br> return type:


*/


public void leaf ()


  {


super.leaf ();


String sshape = "long shape";


super.print ("Shape:" +sshape);


  }


  /**


*<br> Method Description: Extend the flower of the tree


*<br> input Parameters:


*<br> return type:


*/


public void Flower ()


  {


print ("Haha, willow no flower!!") ");


  }


/**


*<br> Method Description: Main method


*<br> input Parameters:


*<br> return type:


*/


public static void Main (string[] args)


  {


osier o = new Osier ();


O.print ("Willow Root:");


O.root ();


o.print ("Willow Trunks:");


O.bolo ();


o.print ("Willow Branch:");


O.branch ();


o.print ("Willow Leaves:");


o.leaf ();


o.print ("Willow Flower:");


O.flower ();


  }


}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.