加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

Java结业测试题(1)

(2011-12-11 17:16:49)
标签:

java结业测试题

it

分类: Java

Java结业测试题 

考试时间:180分钟                                                                                     姓名:__

选择题: (每题1 , 50)

1.      Given the following code:

class Test{

       private int m;

       public static void fun() {

           // some code...

      }

}

How can the member variable m be accessible directly in the method fun()?

A. change private int m to protected int m

B. change private int m to public int m

C. change private int m to static int m

D. change private int m to int m

2.      Which methods are correct overloading methods of the following method:

public void example(){...}

A. public void example( int m){...}

B. public int example(){...}

C. public void example2(){...}

D. public int example ( int m, float f){...}

3.      Given the following fragment of code:

 public class Base{

     int w, x, y ,z;

     public Base(int a,int b){

          x=a; y=b;

          }

     public Base(int a, int b, int c, int d){

          // assignment x=a, y=b

         w=d;

          z=c;

          }

      }

Which expressions can be used at the point of // assignment x=a, y=b?

A. Base(a,b);

B. x=a, y=b;

C. x=a; y=b;

D. this(a,b);

 4.      Given the following definition:

            String s = "story";

      Which of the following expressions are legal?

A. s += "books";

B. char c = s[1];

C. int len = s.length;

D. String t = s.toLowerCase();

5.      What is the return value of the main() method in Java?

A. String

B. int

C. char

D. void

6.      Which are the valid identifiers in Java?

A. fieldname

B. super

C. 3number

D.#number

E. $number

7.      Which are valid Java keywords?

A. const

B. NULL

C. false

D. this

E. native

8.      Which are valid integral expressions in Java?

A. 22

B. 0x22

C. 022

D. 22H

 

9.      Given the following fragment of code, what are results of  i and j after execution?

int i = 1;

int j;

j = i++;

A. 1, 1

B. 1, 2

C. 2, 1

D. 2, 2

 

10.  Which of the following statements are true?

A. >> is the arithmetic right shift operator.

B. >> is the logical right shift operator.

C. >>> is the arithmetic right shift operator.

D. >>> is the logical right shift operator.

 

11.  Which of the following assignments are legal?

A. float a = 2.0

B. double b = 2.0

C. int c = 2

D. long d = 2

12.  Which one of the following arguments is the correct argument of the main() method?

A. char args[]

B. char args[][]

C. String arg[]

D. String args

13.  Which one of the following is correct to create an array?

A. float f[][] = new float[6][6];

B. float []f[] = new float[6][6];

C. float f[][] = new float[][6];

D. float [][]f = new float[6][6];

E. float [][]f = new float[6][];

 

14.  Given the following expression: int m[] = {0, 1, 2, 3, 4, 5, 6 };

Which result of the following expressions equals to the number of the array elements?

A. m.length()

B. m.length

C. m.length()+1

D. m.length+1

15.  Given the following command to run a correct class:  java MyTest a b c

Which statements are true?

A. args[0] = "MyTest a b c"

B. args[0] = "MyTest"

C. args[0] = "a"

D. args[1]= 'b'

16.  Given the following code:

     public class Test{

          static long a[] = new long[10];

         public static void main ( String arg[] ) {

                 System.out.println ( a[6] );

         }

    }

   Which statement is true?

A. Output is null.

B. Output is 0.

C. When compile, some error will occur.

D. When running, some error will occur.

 

17.  Given the following fragment of code:

boolean m = true;

if ( m = false )

     System.out.println("False");

else

     System.out.println("True");

      What is the result of the execution?

A. False

B. True

C. None

D. An error will occur when running.

 

18.  Given the following code:

public class Test{

   public static void main(String arg[]){

      int i = 5;

     do {

              System.out.println(i);

     } while (--i>5);

     System.out.println(“Finished”);

   }

}

What will be output after execution?

A. 5

B. 4

C. 6

D. Finished

E. None

 

19.  What will be output after execution of the following code:

 outer: for(int i=0;i<3; i++)

      inner: for(int j=0;j<2;j++)

           {

              if(j==1) continue outer;

              System.out.println(j++  + “and” +  ++i);

           }

A. 0 and 0

B. 0 and 1

C. 0 and 2

D. 1 and 0

E. 1 and 1

F. 1 and 2

G. 2 and 0

H. 2 and 1

I. 2 and 2

 

20.  Given the following code:

     switch (m)

    {

     case 0: System.out.println("Condition 0");

        case 1: System.out.println("Condition 1");

        case 2: System.out.println("Condition 2");

        case 3: System.out.println("Condition 3");break;

        default: System.out.println("Other Condition");

    }

    Which values of m will cause "Condition 2" is output?

A. 0

B. 1

C. 2

D. 3

E. 4

F. None

 

21.  Which modifiers are legal in Java?

A. private

B. public

C. protected

D. protect

E. friend

 

22.  If a membervariable of a class can be accessible only by the same package, which modifier should be used?

A. private

B. public

C. protected

D. no modifier

E. final

23.  Which modifier should be used to define a constant member variable?

A. static

B. final

C. abstract

D. No modifier can be used

 

24.  Given the following definition of a class:

public class Test {

     private float f = 1.0f;

     int m = 12;

     static int n=1;

     public static void main(String arg[]) {

           Test t = new Test();

           // some code...

     } 

}

Which of the following usage are legal?

A. t.f

B. this.n

C. Test.m

D. Test.n

25.  Given the following code:

1) class Example{

2)      String str;

3)      public Example(){

4)            str= "example";

5)      }

6)      public Example(String s){

7)            str=s;

8)      }

9) }

10) class Demo extends Example{

11) }

12) public class Test{

13)     public void f () {

14)         Example ex = new Example("Good");

15)         Demo d = new Demo("Good");

16) }

Which line will cause an error?

A. line 3

B. line 6

C. line 10

D. line 14

E. line 15

 

26.  Given the following class definition in one source file:

class Base {

      public Base (){ //... }

      public Base ( int m ){ //... }

      protected void fun( int  n ){ //... }

}

public class Child extends Base{

     // member methods

}

Which methods can be added into the Child class correctly?

A. private void fun( int n ){ //...}

B.void fun ( int n ){ //... }

C. protected void fun ( int n ) { //... }

D. public void fun ( int n ) { //... }

E. public m(){ //... }

 

27.  Which statements are correct?

A. In Java single inheritance is allowed, which makes code more reliable.

B. A subclass inherits all methods ( including the constructor ) from the superclass.

C. A class can implement as many interfaces as needed.

D. When a class implements an interface, it can define as many methods of the interface as needed.

28.  In the Test.java source file, which are correct class definitions?

A. public class test {

        public int x = 0;

        public test(int x)           

          {

             this.x = x;

            }

      }

B. public class Test{

                   public int x=0;

                   public Test(int x) {

                          this.x = x;

                   }

          }

C. public class Test extends T1, T2 {

               public int x = 0;

                public Test (int x) {

                     this.x = x;

                }

       }

    D.    public class Test extends T1{

                   public int x=0;

                   public Test(int x){

                          this.x = x;

                   }

           }                                                             

   E.    protected class Test extends T2{

                   public int x=0;

                   public Test(int x){

                           this.x=x;

                  }

          }

 

29.  The Person, Student and Teacher are class names. These classes have the following inheritance relation as shown below:

                      Person

                 |

        ---------------

          |            |

       Student    Teacher

There is the following expression in a Java source file:

              Person p = new Student();

Which one of the following statements are true?

A. The expression is legal.

B. The expression is illegal.

C. Some errors will occur when compile.

D. Compile is correct but it will be wrong when running.

30.  The Person, Student and Teacher are class names. These classes have the following inheritance relation as shown below:

               Person

                |

          ---------------

          |             |

       Student    Teacher

       In Java source file a specific method has an argument. In order to handle all these classes in this method which type of argument of this method should be used?

A. Person

B. Student

C. Teacher

D. Object

E. None of them can be used. 


0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有