<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 2018-05-11 周測試題 在 Eclipse 中新建項目,將以下試題完成,時間 60 min。 **注意:格式,命名規范,注釋** 1、實現在控制臺輸出九九乘法表。 ~~~ public class Test { public static void main(String[] args) { for (int i = 1; i <= 9; i++) { for (int j = 1; j <= i; j++) { System.out.print("" + i + " * " + j + " = " + (i * j) + "\t"); } System.out.println(); } } } ~~~ 2、定義方法sum,要求實現兩個數之和的運算,要求在main方法中調用。 ~~~ public class Test2 { public static int sum(int a, int b) { return a + b; } public static void main(String[] args) { int i = 10; int j = 20; System.out.println("" + i + " + " + j + " = " + Test2.sum(i, j) + ""); } } ~~~ 3、請寫一個方法打印數組的內容,實現遍歷數組,要求在main方法中調用。 > 提示:在main方法中定義一個數組,然后將數組作為參數傳給方法,在方法中打印結果"[a,b,c,....]" ~~~ public class Test3 { public static void main(String[] args) { String[] arr1 = {"a","b","c"}; String[] arr2 = {}; String[] arr3 = null; System.out.println(printArray(arr1)); System.out.println(printArray(arr2)); System.out.println(printArray(arr3)); } public static String printArray(String[] arr) { // [a,b,c] String result = ""; if (null == arr) { result = "數組為null"; } else { if (arr.length == 0) { result = "數組長度為 0"; } else { result = "["; for (int i = 0; i < arr.length; i++) { if (i == arr.length - 1) { result += arr[i]; } else { result += arr[i] + ","; } } result += "]"; } } return result; } } ~~~ 4、請將消費者在商城購物這個場景抽象出類,并編寫一個客戶端類,實現“小明在歐尚買了一件T恤”這樣一個購物行為。 ~~~ public class Customer { private String name; public Customer(String name) { super(); this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } } ~~~ ~~~ public class Market { private String name; public Market(String name) { super(); this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } } ~~~ ~~~ public class Product { private String name; public Product(String name) { super(); this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } } ~~~ ~~~ public interface ShoppingServiceInter { void shopping(Customer cus, Market market, Product product); } ~~~ ~~~ public class ShoppingService implements ShoppingServiceInter { public void shopping(Customer cus, Market market, Product product) { System.out.println("" + cus.getName() + "在" + market.getName() + "買了件" + product.getName() + ""); } } ~~~ ~~~ public class Client { public static void main(String[] args) { Customer customer = new Customer("小明"); Market market = new Market("歐尚"); Product product = new Product("T恤"); ShoppingService service = new ShoppingService(); service.shopping(customer, market, product); } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看