JAVA程序员笔试题目与答案.docx

上传人:b****5 文档编号:7635914 上传时间:2023-01-25 格式:DOCX 页数:6 大小:17.28KB
下载 相关 举报
JAVA程序员笔试题目与答案.docx_第1页
第1页 / 共6页
JAVA程序员笔试题目与答案.docx_第2页
第2页 / 共6页
JAVA程序员笔试题目与答案.docx_第3页
第3页 / 共6页
JAVA程序员笔试题目与答案.docx_第4页
第4页 / 共6页
JAVA程序员笔试题目与答案.docx_第5页
第5页 / 共6页
点击查看更多>>
下载资源
资源描述

JAVA程序员笔试题目与答案.docx

《JAVA程序员笔试题目与答案.docx》由会员分享,可在线阅读,更多相关《JAVA程序员笔试题目与答案.docx(6页珍藏版)》请在冰豆网上搜索。

JAVA程序员笔试题目与答案.docx

JAVA程序员笔试题目与答案

JAVA程序员笔试题目与答案

1.Given:

 

Integer i = new Integer (42);

Long l = new Long (42);

Double d = new Double (42.0); 

Which two expressions evaluate to True?

A. (i == 1)

B. (i == d)

C. (d == 1)

D. (i.equals (l))

E. (d.equals (l))

F. (i.equals (42)) 

G. none of above

Answer:

          

 

2. Given:

 

public class Foo {

    public static void main (String [] args)  {

        StringBuffer a = new StringBuffer("A");

        StringBuffer b = new StringBuffer ("B");

        operate (a,b);

        System.out.println(a + "," +b);

    }

    static void operate(StringBuffer x, StringBuffer y) {

        x.append(y);

        y = x;

    }

}

What is the result?

 

A. The code compiles and prints “A,B”.

B. The code compiles and prints “A,A”.

C. The code compiles and prints “B,B”.

D. The code compiles and prints “AB,B”.

E. The code compiles and prints “AB,AB”.

F. The code does not compile because “+” cannot be overloaded for StringBuffer. 

Answer:

        

 

 

3.Given:

class BaseClass {

    private float x = 1.0f ;

    protected float getVar() {return x;}

}

class Subclass extends BaseClass {

    private float x = 2.0f;

    //insert here

}

Which two are valid examples of method overriding?

A. float getVar() { return x;}

B. public float getVar() { return x;}

C. public double getVar() { return x;}

D. protected float getVar() { return x;}

E. public float getVar(float f) { return f;}

Answer:

       

 

4. Which of the following are methods of the Runnable interface

A) run

B) start

C) yield

D) stop

Answer:

            

 

5. Which of the following are legal statements?

A) float f=1/3;

B) int i=1/3;

C) float f=1.01;

D) double d=999d;

Answer:

                

 

6. Given:

public class test(

    public static void main(string[] args){

        String foo = args[1];

        String baz = args[2];

        String bax = args[3];

    }

And the command line invocation:

 

Java Test red green blue 

What is the result?

 

A. baz has the value of “”

B. baz has the value of null

C. baz has the value of “red”

D. baz has the value of “blue”

E. bax has the value of “green”

F. the code does not compile

G. the program throws an exception 

Answer:

      

 

 

7. Which of the following statements are true?

A) The garbage collection algorithm in Java is vendor implemented

B) The size of primitives is platform dependent

C) The default type for a numerical literal with decimal component is a float.

D) You can modify the value in an Instance of the Integer class with the setValue method

Answer:

         

 

8. Given:

 

int i = 1, j = 10;

do {

    if(i++ > --j) continue;

} while(i<5); 

After execution, what are the values for i and j?

 

A. i = 6 and j= 5

B. i = 5 and j= 5

C. i = 6 and j= 4

D. i = 5 and j= 6

E. i = 6 and j= 6 

Answer:

      

 

 

9. Given:

import java.io.IOException; 

public class ExceptionTest {

    public static void main (String[] args){

        try {

            methodA();

        } catch (IOException e) {

            System.out.println("Caught IOException");

        } catch (Exception e) {

            System.out.println("Caught Exception");

        }

    }

    public void methodA(){

        throw new IOException();

    }

What is the result?

A. The code will not compile.

B. The output is:

 caught exception.

C. The output is:

 caught IOException.

D. The program executes normally without printing a message.

Answer:

       

 

10. Given:

 

public class Test {

    public static String output = "";

    public static void foo(int i) {

        try { 

            if(i==1) {

                throw new Exception (); 

            } 

            output += "1"; 

        } catch(Exception e) { 

            output += "2"; 

            return; 

        } finally {

            output += "3"; 

        } 

        output += "4"; 

    } 

    public static void main (String args[]){

        foo(0); 

        foo

(1); 

        //line 24

    } 

}

What is the value of the variable output at line 24?

 

Answer:

      

 

 

11. Given:

 

public class Foo implements Runnable {      //line 1

    public void run (Thread t) {            //line 2

        System.out.println("Running.");

    }

    public static void main (String[] args) {

        new Thread(new Foo()).start();

    }

What is the result?

A. An exception is thrown 

B. The program exists without printing anything

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

D. An error at line 2 causes the compilation to fail.     

E. “Running” is printed and the program exits

Answer:

     

 

12. Given:

 

ClassOne.java

package com.abc.pkg1;

public class ClassOne {

    private char var = ‘a’;

    char getVar() { return var; }

}

ClassTest.java

package com.abc.pkg2;

import com.abc.pkg1.ClassOne;

public class ClassTest extends ClassOne {

    public static void main(String[]args) {

        char a = new ClassOne().getVar();       //line 5

        char b = new ClassTest().getVar();      //line 6

    }

}     

What is the result?

 

A. Compilation will fail.

B. Compilation succeeds and no exceptions are thrown.

C. Compilation succeeds but an exception is thrown at line 5 

in ClassTest.java.

D. Compilation succeeds but an exception is thrown at line 6 

in ClassTest.java. 

Answer:

      

 

13. Which is a valid identifier?

 

A. false

B. default

C. _object

D. a-class 

Answer:

      

 

14 If you run the code below, what gets printed out?

 

String s=new String("Bicycle");

int iBegin=1;

char iEnd=3;

System.out.println(s.substring(iBegin,iEnd));

A) Bic 

B) ic 

C) icy 

D) error:

 no method matching substring(int,char) 

Answer:

      

 

15 What will happen when you attempt to compile and run the following code

public class MySwitch{

public static void main(String argv[]){

    MySwitch ms= new MySwitch();

    ms.amethod();

    }

public void amethod(){

           int k=10; 

        switch(k){ 

        default:

 //Put the default at the bottom, not here

            System.out.println("This is the default output"); 

            break; 

         case 10:

 

            System.out.println("ten");

         case 20:

 

            System.out.println("twenty"); 

               break; 

       }

    }

}

A) None of these options

B) Compile time error target of switch must be an integral type

C) Compile and run with output "This is the default output"

D) Compile and run with output of the single line "ten"

Answer:

      

 

 

 

 

 第二部分 :

J2EE部份

 

1.简述J2EE Architecture。

  

2.简述JSP在Web Container中的生命周期。

 

3.如何使用数据库连接池?

有什么好处?

 

4.列举您在开发中用到的一些模式与框架。

模式与框架有什么区别吗?

 

 5. 列举您知道的几种持久化技术。

 

 6.什么是SOA?

 WebServices与SOA有什么样的关系?

 

 第三部分 :

通用知识

 

1.简述OSI七层协议。

IP/TCP/UDP/HTTP/SMTP分别属于哪一层?

 

 2.简述TMN,TOM,eTOM, NGOSS四个模型之间的关系。

 

 3.什么是数据库系统?

列举几个常见的数据库系统。

 

 4.请简单描述软件开发过程的主要阶段。

 

 5.请将下面一段文字翻译成中文。

An enterprise service bus (ESB) is a pattern of middleware that unifies and connects services, applications and resources within a business. Put another way, it is the framework within which the capabilities of a business’ applications are made available for reuse by other applications throughout the organization and beyond. The ESB is not a new software product — it’s a new way of looking at how to integrate applications, coordinate resources and manipulate information. Unlike many previous approaches for connecting distributed applications, for example RPC or distributed objects, the ESB pattern enables the connection of software running in parallel on different platforms, written in different programming languages and using different programming models.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1