Big Data Java Foundation Seventh day job

Source: Internet
Author: User

First question: Interface iwhite{    public void white ();} Interface irich{    public void rich ();} Interface ibeauti{    public void beauti ();} Interface iwrb extends iwhite,irich,ibeauti{};class richman{    public  void tomarry (IWRB&NBSP;WS) {        ws.white ();         ws.rich ();         ws.beauti ();     }}class marry{    public static void main ( String[] args) {        richman rm = new  RichMan ();         rm.tomarry (NEW&NBSP;IWRB () {             public void white () {                 system.out.println ("I ' m white !");             }             public void rich () {                 system.out.println ("I ' m rich !");             }             public void beauti () {                 system.out.println ("I ' m beauti !");             }         });     }} The second question:class trianle{    private int  A;    private int b;&nbSp;   private int c;    public void setedgea (int  Edge) {        this.a = edge;    }     public void setedgeb (Int edge) {        &NBSP;THIS.B&NBSP;=&NBSP;EDGE;&NBSP;&NBSP;&NBSP;&NBSP;}&NBSP;&NBSP;&NBSP;&NBSP;PUBLIC&NBSP;VOID&NBSP;SETEDGEC ( Int edge) {        this.c = edge;     }    public void check ()  throws Exception{         int max;        int other;         if (a >= b && a >=  c) {            max = a;             other = b + c;        } Else if (b >= a && b >= c) {             max = b;             other = a + c;        } else{            max = c;             other = a + b;         }        if (max >  Other) {            throw new exception (" The length of the triangle side is set incorrectly! ");        }else{             System.out.println ("It's a triangle! ");        }    }}class throwdemo{     public static void main (String[] args) {         try{            Trianle  Trianle = new trianle ();             trianle.setedgea (;            ) Trianle.setedgea (&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;TRIANLE.SETEDGEC);             trianle.check ();         }catch (exception e) {             e.printstacktrace ();        }     }} third question: Class invalidparamexcetion extends exception{    public  Invalidparamexcetion (string msg) {        super (msg);   &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;SYSTEM.OUT.PRINTLN (msg);    }}class person{     private string birthday;        public  string getbirthday () {        return birthday;     }    public void setbirthday (Int year,int month,int  day)  throws invalidparamexcetion{        if (year  < 1900 | |  year > 2016) {            throw  new invalidparamexcetion ("The year is inappropriate, does not exist"  + year +  "month");        &nBSP;}         if (month < 1 | | &NBSP;MONTH&NBSP;&GT;&NBSP;12) {            throw  new invalidparamexcetion ("Month does not fit, does not exist"  + month +  "month");         }        if (day < 1 | | &NBSP;DAY&NBSP;&GT;&NBSP;31) {            throw  new invalidparamexcetion ("date inappropriate, not present"  + day +  "Day");         }else{            boolean  monday =  (month == 1 | |  month == 3 | |  month == 5 | |  month == 8 | |  month == 10 | | &NBSP;MONTH&NBSP;==&NBSP;12);          &Nbsp;  if (monday && day != 31) {                 throw new invalidparamexcetion ("date not appropriate, Does not exist " + day + " Day ");             }else if (month == 2 && day > 29) {                 throw new invalidparamexcetion (" The date is inappropriate and does not exist " + day + " Day ");             }else if (month == 2 && year % 4 != 0 & & day == 29) {                 throw new invalidparamexcetion ("date inappropriate, not present"  + day +  "Day");             }        }         birthday =  "Birthday is:"  + year +  "Year"  + month  +  "Month"  + day +  "Day";    }}class throwdemo{     public static void main (String[] args) {         try{            person person  = new person ();             Person.setbirthday (2016,2,10);             System.out.println (Person.getbirthday ());         }catch ( Invalidparamexcetion e) {             E.printstacktrace ();       &nbSP;&NBSP;}&NBSP;&NBSP;&NBSP;&NBSP}} Fourth: currently in 07 directory 1, create Pack.java file package a.b.c.d;class pack{     public static void main (String[] args) {         system.out.println ("Hello world ...");     }}2, creating Classes Directory 3, compiling   JAVAC&NBSP;-D&NBSP;CLASSES/&NBSP;PACK.JAVA4, packing &NBSP;JAR&NBSP;CVFE&NBSP;PACK.JAR&NBSP;A.B.C.D.PACK&NBSP;-C  classes/ .5, perform  java -jar pack.jar a.b.c.d.pack fifth: 1, create 08 folder 2, cmd into 08 file execution, Java  -jar pack.jar a.b.c.d.pack


This article from "Do Not Tang donation" blog, please be sure to keep this source http://senlinmin.blog.51cto.com/6400386/1772343

Big Data Java Foundation Seventh day job

Related Article

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.