Java experimental questions 3_5_ Lindaru equalities station

Source: Internet
Author: User

Import java.util.scanner;//write Code hereclass dog{string breed,color;int weight;} Class Spotteddog extends Dog{private String spotcolor; Spotteddog (String a,int b,string c,string d) {breed=a;weight=b;color=c;spotcolor=d;} void Showbreed () {System.out.println (breed);} void Spotinfo () {System.out.println (Spotcolor);}} Class Unspotteddog extends Dog{unspotteddog (String a,int b,string c) {breed=a;weight=b;color=c;} void Showbreed () {System.out.println (breed);}} public class Main {public static void main (string[] args) {Scanner scan = new Scanner (system.in); String str1 = Scan.next (); int age1 = Scan.nextint (); String str2 = Scan.next (); String STR3 = Scan.next (); String STR4 = Scan.next (); int age2 = Scan.nextint (); String STR5 = Scan.next (); Spotteddog redspot = new Spotteddog (Str1,age1, str2, STR3); Unspotteddog rover = new Unspotteddog (STR4, Age2, STR5); Redspot.showbreed (); Redspot.spotinfo (); Rover.showbreed ();}}

  

Java experimental Questions 3_5_ Lindaru equalities station

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.