Edzy_Java

            BlogJava :: 首頁 ::  ::  ::  :: 管理 ::
            58 隨筆 :: 12 文章 :: 11 評論 :: 0 Trackbacks

          [第一部分:選擇題]

          QUESTION NO: 1

          1、public class Test {
            public static void changeStr(String str){
              str="welcome";
            }
            public static void main(String[] args) {
              String str="1234";
              changeStr(str);
              System.out.println(str);
            }
          }
          Please write the output result :

          QUESTION NO:2

          1. public class Test {
          2. static boolean foo(char c) {
          3. System.out.print(c);
          4. return true;
          5. }
          6. public static void main( String[] argv ) {
          7. int i =0;
          8. for ( foo(’A’); foo(’B’)&&(i<2); foo(’C’)){
          9. i++ ;
          10. foo(’D’);
          12. }
          13. }
          14. }
          What is the result?

          A. ABDCBDCB
          B. ABCDABCD
          C. Compilation fails.
          D. An exception is thrown at runtime.

          QUESTION NO: 3

          1. class A {
          2. protected int method1(int a, int b) { return 0; }
          3. }
          Which two are valid in a class that extends class A? (Choose two)
          A. public int method1(int a, int b) { return 0; }
          B. private int method1(int a, int b) { return 0; }
          C. private int method1(int a, long b) { return 0; }
          D. public short method1(int a, int b) { return 0; }
          E. static protected int method1(int a, int b) { return 0; }

          QUESTION NO: 4

          1. public class Outer{
          2. public void someOuterMethod() {
          3. // Line 3
          4. }
          5. public class Inner{}
          6. public static void main( String[]argv ) {
          7. Outer o = new Outer();
          8. // Line 8
          9. }
          10. }
          Which instantiates an instance of Inner?
          A. new Inner(); // At line 3
          B. new Inner(); // At line 8
          C. new o.Inner(); // At line 8
          D. new Outer.Inner(); // At line 8//new Outer().new Inner()

          QUESTION NO: 5

          Which method is used by a servlet to place its session ID in a URL that is written to the servlet’s response output stream?
          A. The encodeURL method of the HttpServletRequest interface.
          B. The encodeURL method of the HttpServletResponse interface.
          C. The rewriteURL method of the HttpServletRequest interface.
          D. The rewriteURL method of the HttpServletResponse interface.

          QUESTION NO: 6

          Which of the following statements regarding the lifecycle of a session bean are correct? 
          1. java.lang.IllegalStateException is thrown if SessionContext.getEJBObject() is invoked when a stateful session bean instance is passivated. 
          2. SessionContext.getRollbackOnly() does not throw an exception when a session bean with bean-managed transaction demarcation is activated. 
          3. An exception is not thrown when SessionContext.getUserTransaction() is called in the afterBegin method of a bean with container-managed transactions. 
          4. JNDI access to java:comp/env is permitted in all the SessionSynchronization methods of a stateful session bean with container-managed transaction demarcation. 
          5. Accessing resource managers in the SessionSynchronization.afterBegin method of a stateful session bean with bean-managed transaction does not throw an exception.

          [第二部分:概念題]

          1.   描述Struts體系結構?對應各個部分的開發工作主要包括哪些?

          2.   XML包括哪些解釋技術,區別是什么?

          3.   JSP有哪些內置對象和動作?它們的作用分別是什么?

          4、SQL問答題

          SELECT * FROM TABLE

          SELECT * FROM TABLE

          WHERE NAME LIKE '%%' AND ADDR LIKE '%%'

          AND (1_ADDR LIKE '%%' OR 2_ADDR LIKE '%%'

          OR 3_ADDR LIKE '%%' OR 4_ADDR LIKE '%%' )

          的檢索結果為何不同?

          5、SQL問答題

          表結構:

          1、   表名:g_cardapply

          字段(字段名/類型/長度):

          g_applyno     varchar   8;//申請單號(關鍵字)

          g_applydate   bigint   8;//申請日期

          g_state     varchar   2;//申請狀態

          2、   表名:g_cardapplydetail

          字段(字段名/類型/長度):

          g_applyno     varchar   8;//申請單號(關鍵字)

          g_name     varchar   30;//申請人姓名

          g_idcard     varchar   18;//申請人身份證號

          g_state     varchar   2;//申請狀態

          其中,兩個表的關聯字段為申請單號。

          題目:

          1、   查詢身份證號碼為440401430103082的申請日期

          2、   查詢同一個身份證號碼有兩條以上記錄的身份證號碼及記錄個數

          3、   將身份證號碼為440401430103082的記錄在兩個表中的申請狀態均改為07

          4、   刪除g_cardapplydetail表中所有姓李的記錄

          [JAVA題庫:5道JAVA題]

          Module 1 – Getting Started

          Q1.What will happen when you compile and run the following code?

          (4)

          public class MyClass{
          static int i;
          public static void main(String argv[]){
          System.out.println(i);
          }
          }

          1) Error Variable i may not have been initialized
          2) null
          3) 1
          4) 0

          Q2.Which of the following will compile without error (2)(3)
          1)
          import java.awt.*;
          package Mypackage;
          class Myclass {}
          2)
          package MyPackage;
          import java.awt.*;
          class MyClass{}
          3)
          /*This is a comment */
          package MyPackage;
          import java.awt.*;
          class MyClass{}

          Q3.What will happen if you try to compile and run the following code (1)
          public class MyClass {
          public static void main(String arguments[]) {
          amethod(arguments);
          }
          public void amethod(String[] arguments) {
          System.out.println(arguments);
          System.out.println(arguments[1]);
          }
          }
          1) error Can't make static reference to void amethod.
          2) error method main not correct
          3) error array must include parameter
          4) amethod must be declared with String

          Q4.Given the following code(2)
          public class Sytch{
          int x=2000;
          public static void main(String argv[]){
          System.out.println("Ms "+argv[1]+"Please pay $"+x);
          }
          What will happen if you attempt to compile and run this code with the command line
          java Sytch Jones Diggle
          1) Compilation and output of Ms Diggle Please pay $2000
          2) Compile time error
          3) Compilation and output of Ms Jones Please pay $2000
          4) Compilation but runtime error

          Q5.You have a public class called myclass with the main method defined as follows(4)
          public static void main(String parm[]){
          System.out.println(parm[0]);
          }

          If you attempt to compile the class and run the program as follows
          java myclass hello
          What will happen?
          1) Compile time error, main is not correctly defined
          2) Run time error, main is not correctly defined
          3) Compilation and output of java
          4) Compilation and output of hello

          [JAVA題庫:考考你]

          1、Examine the following code which includes an inner class:

           public final class Test4{
            class Inner{
              void test(){
                if (Test4.this.flag);{
               sample();
                }
              }
           }
           
           private boolean flag=false;
           public void sample(){
           System.out.println("Sample");
           }
           public Test4(){
           (new Inner()).test();
           }
           public static void main(String args[]){
           new Test4();
           }
           }

           What is the result:
             A.Print out “Sample”
             B.Program produces no output but termiantes correctly.
             C. Program does not terminate.
             D.The program will not compile

          答案:A

          2、What will happen when you attempt to compile and run the following code?

          class Base {
              int i = 99;
              public void amethod() {
                  System.out.println("Base.amethod()");
              }
              Base() {
                  amethod();
              }
          }

          public class Derived extends Base{
              int i = -1;
              public static void main(String argv[]) {
                  Base b = new Derived();
                  System.out.println(b.i);
                  b.amethod();
              }
               public void amethod() {
                  System.out.println("Derived.amethod()");
              }
          }

           A. Derived.amethod()
              -1
              Derived.amethod()

           B. Derived.amethod()
              99
              Derived.amethod()
           C. 99
              Derived.amethod()
           D.
              Compile time error

          答案:B

          3、public class Test{
               public static void main(String[] args){
               StringBuffer a=new StringBuffer("A");
               StringBuffer b=new StringBuffer("B");
               operate(a,b);
               System.out.pintln(a+","+b);
              }
             public static void operate(StringBuffer x, StringBuffer y){
              x.append(y);
              y=x;
             }
             }

          what is the output?

          答案:"AB,B"

          4、public class Test{
             public static void stringReplace(String text){
               text=text.replace('j','l');
              }
              public static void bufferReplace(StringBuffer text){
                text=text.append("c");
               }
             public static void main(String args[]){  
                String textString=new String("java");
                StringBuffer textBuffer=new StringBuffer("java");
                stringReplace(textString);
                bufferReplace(textBuffer);
                System.out.println(textString+textBuffer);
              }
           }
             what is the output?

          答案:"javajavac"

          5、public class Test{
            static void leftshift(int i, int j){
                i<<=j;
            }

            public static void main(String args[]){
              int i=4, j=2;

             leftshift(i,j);
             System.out.println(i);
           }
          }
          what is the result?

          答案:4

          Java編程練習題庫

          【1】編譯運行如下程序的結果是什么 ?
            class InvalidIndexException extends Exception{
            private int i;
            InvalidIndexException(int a){
              i=a;
            }
            public String toString(){
              return i+" is out of boundary--0 < i < 8";
            }
          }

          public class Weekdays{

            public static void main(String args[]){
                try{
                  for (int i=1; i < 9; i++) System.out.println(i+"---"+giveName(i));
                }catch(InvalidIndexException e){
                  System.out.println(e.toString());
                }finally{ System.out.println("These days makes up a week.");}
            }

            public static String giveName(int d) {
              String name;
              switch(d){
                case 1: name="Monday"; break;
                case 2: name="Tuesday"; break;
                case 3: name="Wednesday"; break;
                case 4: name="Thursday"; break;
                case 5: name="Friday"; break;
                case 6: name="Saturday"; break;
                case 7: name="Sunday"; break;
                default: throw new InvalidIndexException(d);
              }
              return name;
            }
          }

          (A)  1---Monday
                 2---Tuesday
                 3---Wednesday
                 4---Thursday
                 5---Friday
                 6---Saturday
                 7---Sunday
                 These days makes up a week.
          (B)  1---Monday
                 2---Tuesday
                 3---Wednesday
                 4---Thursday
                 5---Friday
                 6---Saturday
                 7---Sunday
                 8 is out of boundary--0 < i < 8
                 These days makes up a week.
          (C)  1---Monday
                 2---Tuesday
                 3---Wednesday
                 4---Thursday
                 5---Friday
                 6---Saturday
                 7---Sunday
          (D) 編 譯 不 能 通 過。

          答 案:(B)

          【2】 有 如 下 一 段Java 程 序:
          import java.io.*;
          public class Quiz1{
              public static void main(String arg[]){
                  int i;
                  System.out.print("Go ");
                  try{
                      System.out.print("in ");
                      i=System.in.read();
                      if (i=='0') {throw new MyException();}
                      System.out.print("this ");
                  }
                  catch(IOException e){}
                  catch(MyException e){
                      System.out.print("that ");
                  }
                  System.out.print("way.\n");
              }
          }
          class MyException extends Exception{}
                 運 行 該 程 序 后 輸 入 字 符'0', 請 問 運 行 結 果 為 何 ?
          (A)Go in this way
          (B)Go in that this way
          (C)Go in that
          (D)Go in that way

          答 案:(D)

          【3】 下 面 程 序 的 輸 出 是 什 么 ?
              public class Quiz2{
              public static void main(String args[]){
                  try {throw new MyException();
                  }catch(Exception e){
                      System.out.println("It's caught!");
                  }finally{
                      System.out.println("It's finally caught!");
                  }
              }
          }
          class MyException extends Exception{}

          (A)It's finally caught!
          (B)It's caught!
          (C)It's caught!
               It's finally caught!
          (D)無 輸 出

          答 案:(C)

          【4】 下 面 的 程 序 是 一 個 嵌 套 例 外 處 理 的 例 子, 請 選 擇 其 運 行 結 果:
              public class Quiz3{
              public static void main(String args[]){
                  try{
                      try{
                          int i;
                          int j=0;
                          i=1/j;
                      }catch(Exception e){
                          System.out.print("Caught ");
                          throw e;
                      }finally{
                         System.out.print("Inside ");
                      }
                  }catch(Exception e){
                      System.out.print("Caught ");
                  }finally{
                      System.out.print("Outside\n");
                  }
              }
          }

          (A)Caught Outside
          (B)Caught Inside
          (C)Caught Caught Outside
          (D)Caught Inside Caught Outside
           
          答 案:(D)

          【5】Java 運 行 時 例 外 是 在 運 行Java 程 序 時 由Java 運 行 時 系 統 負 責 拋 出 的 一 系 列 例 外。 本 章 例 程 中 所 提 到 的 許 多 例 外 就 是Java 運 行 時 例 外( 詳 見 例8.2 等)。 請 詳 細 閱 讀 例 程, 選 擇 對 于 如 下 的 程 序, 系 統 將 拋 出 哪 個 運 行 時 例 外。
          class Quiz4{
              int a[]=new int[10];
              a[10]=0;
          }

          (A)ArithmeticException
          (B)ArrayIndexOutOfBoundsException
          (C)NegativeArraySizeException
          (D)IllegalArgumentException

          答 案:(B)

          【6】 為 了 編 程 需 要, 現 需 自 己 編 寫 一 個 例 外 類。 一 般 說 來, 下 面 聲 明 哪 個 最 為 合 適 ?
          (A)class myClass extentds Exception{...
          (B)class myException extends Error{...
          (C)class myException extends RuntimeException{...
          (D)class myException extends Exception{...

          答 案:(D)

          posted on 2006-11-16 20:50 lbfeng 閱讀(1555) 評論(0)  編輯  收藏 所屬分類: 專業考試題庫
          主站蜘蛛池模板: 收藏| 大余县| 南宫市| 抚宁县| 昌乐县| 伊宁市| 阿拉善盟| 辰溪县| 崇义县| 枝江市| 筠连县| 偃师市| 南开区| 淳化县| 五大连池市| 方正县| 眉山市| 扎兰屯市| 天水市| 舒城县| 封开县| 青铜峡市| 文昌市| 卓尼县| 长春市| 北海市| 阿图什市| 阜新市| 婺源县| 天门市| 思南县| 五家渠市| 油尖旺区| 德保县| 通江县| 泰宁县| 阿拉善盟| 博客| 布尔津县| 凯里市| 登封市|