复习题目

Set1_Question

 

1. Which two of the following situations will result in the init() method of a servlet being invoked?

A. Every time a new client accesses the servlet

B. When the server automatically reloads the servlet

C. When a HTTP INIT type request is made by a client

D. When the servlet is put into service after loading and instantiation

 

2. If a server has URL rewriting enabled, what is the result of using the encodeURL() method of the HttpResponse interface?

A. Encryption of sensitive client data in the URL

B. Increased performance due to browser specific information being encoded in the URL

C. Redirection of all subsequent requests to a unique domain specified as a URL parameter

D. Addition of a client's session ID to the URL in a query string

 

 

3. A developer wants to measure how many times a servlet has been invoked. Which listener could be used to accomplish this task?

A. HttpSessionListener

B. ServletContextListener

C. ServletRequestListener

D. ServletRequestAttributeListener

 

4. A Web application contains a single servlet that handles all types of requests. Within the Web application there is an HTML page that contains a form that uses a POST type request. There are also hyperlinks with query strings associated with them. The servlet must handle both HTML form and hyperlink requests. Which two methods of the HttpServlet class should be overridden by the servlet programmer?

A. doGet()

B. doPut()

C. doPost()

D. doQuery()

E. doForm()

 

5.

 

Given:

 String foo = “blue”;

 Boolean[]bar = new Boolean [1];

 if (bar[0]) {

 foo = “green”;

 }

What is the result?

 

A. Foo has the value of “”

B. Foo has the value of null.

C. Foo has the value of “blue”

D. Foo has the value of “green”

E. An exception is thrown.

F. The code will not compile.

 

6.

Exhibit:

 public class X {

      public static void main (String[]args) {

      String s1 = new String (“true”);

      Boolean b1 = new Boolean (true);

      if (s1.equals(b1)) {

      System.out.printIn(“Equal”);

                      }

                                  }

               }

What is the result?

A. The program runs and prints nothing.

B. The program runs and prints “Equal”

C. An error at line 5 causes compilation to fail.

D. The program runs but aborts with an exception.

 

 

7.

 

Given:

 public class Foo {

 public static void main (String []args) {

 int i = 1;

 int j = i++;

 if ((i>++j) && (i++ ==j)) {

 i +=j;

 }

 }

 }

 

What is the final value of i?

A. 1

B. 2

C. 3

D. 4

E. 5

 

8.Exhibit:

 public class X {

 public static void main (String[]args) {

 string s = new string (“Hello”);

 modify(s);

 System.out.printIn(s);

 }

 

 public static void modify (String s) {

 s += “world!”;

 }

 }

 

What is the result?

A. The program runs and prints “Hello”

B. An error causes compilation to fail.

C. The program runs and prints “Hello world!”

D. The program runs but aborts with an exception.

 

9.sleep() wait() 有什么区别?

 

10.Math.round(11.5)等于多少? Math.round(-11.5)等于多少?

 

11.有状态session bean与无状态session bean的区别?

 

12.EJBJAVA BEAN的区别?

 

13.HashMapHashtable的区别?

 

以下の问题1620を○×で回答してください。

 

问题14

1つのクラスに同じ名前のメソッドがあると、コンパイルエラーになる。

 

问题15

JDK1.4で、メソッドが引数を必要とする场合、引数を指定しないと、コンパイルエラーになる。

 

问题16

メソッドは、复数の戻り値を返すことができない。

 

问题17

下记プログラムの実行结果は、どのようになりますか?(A~Eの中から1つ选択)

11行目.int x = 1,y = 6;

12行目.while(y--) {

13行目. x++;

14行目.}

15行目.System.out.println("x="+ x + "y=" + y);

 

A.画面にx=6y=0と表示される。

B.画面にx=7y=0と表示される。

C.画面にx=6y=-1と表示される。

D.画面にx=7y=-1と表示される。

E.コンパイルエラーになる。

 

问题18

下记プログラムの実行结果は、どのようになりますか?(A~Eの中から1つ选択)

class sample {

 public static void main(String args[]) {

    int i=0;

  for(; i<4; i+=2) {

   System.out.print( i );

  }

    System.out.print( i );

 }

 

}

 

A.画面に024と表示される。

B.画面に0245と表示される。

C.画面に01234と表示される。

D.コンパイルエラーになる。

E.実行时に例外が発生する。

 

 

table1table2の例データです                                    

table1                           table2            

id    seq   value              id    seq   value

id001      1     111         id001      3     a

id001      2     222         id001      2     b

id002      1     111         id002      1     c

id002      3     222         id002      3     d

                                                                            

table2のデータをtable1に登录する(ただし、seqという项目调整要)                                                                                

この公式の内

■【2】の意味 はtable1id001内、最大のseq2

■【1】の意味 はtable2id001内、このレコードのseqは一番小さい

 

■次の公式も同じように类推する

                                      

上记の例は、table1は结果的に下记のように変更される                                       

赤字が新しく登录されるデータ                                         

                                         

table1                                        

id    seq   value                           

id001      1     111                      

id001      2     222                      

id001      3     b         2+1=3           

id001      4     a          2+2=4           

id002      1     111                      

id002      3     222                      

id002      4     c          3+1=4           

id002      5     d         3+2=5           

                                         

       下记の二つ选択肢を一つを选択して実现方法を考えています。                                  

1     Javaプログラムをマイン方法として上记の登录を実现する                                  

2     SQLをマイン方法として上记の登录を実现する(复数のSQL可)                             

                                         

※注意、上记に书いたtableのデータが例だけです、実际のデータがそうではない            

       なので、id='id001'などのロジックを避けてください                               

       一般的なロジックで実装してください          

 

 

Select tab1.id,tab1.seq,tab1.value from table1 tab1 left join table2 tab2 on

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ホワイトボックステスト                 

①単体テストケースを洗い出してください。                    

※年度というのは、例えば、2011年度は2011・4・1~2012・3・31ということです。                    

       private String getYearArray(int count){             

              StringBuffer buf = new StringBuffer();      

              String rdoReferClass = getParameter("rdoReferClass"); //画面から取得      

 

              StringBuffer bufTmp ;  

 

              Calendar cal = GPRCommon.getFiscalYearObj(); //戻り値:YYYY年度のみが含むCalendarオブジェクト。    

              SimpleDateFormat df = new SimpleDateFormat("yyyy"); 

 

              for (int i = 0; i < count; i++){     

                     buf.append("'"+df.format(cal.getTime())+"'");

                     bufTmp = new StringBuffer();

                     bufTmp.append(df.format(cal.getTime()));

 

                     if(rdoReferClass.equals("Monthly")){  

                            iMonthArr[i]=Integer.parseInt(bufTmp.toString());

                     } else {  

                            iYearArr[i]=Integer.parseInt(bufTmp.toString());

                     }    

                     if((i + 1) < count){

                            buf.append(",");

                            cal.add(Calendar.YEAR,-1);

                     }    

              }           

              return buf.toString();           

       }    

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ブラックボックステスト

②下记の画面を见るだけで、単体テストケースを洗い出してください。

                                

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章