JAVA程序员笔试题目与答案

更新时间:2023-06-19 10:37:24 阅读: 评论:0

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”.
rrb400B. 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 becau “+” cannot be overloaded for StringBuffer. 
Answer:       
 
 
3.Given:
class BaClass {
    private float x = 1.0f ;
    protected float getVar() {return x;}
}
class Subclass extends BaClass {
    private float x = 2.0f;
    //inrt 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 tValue 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 caus compilation to fail. 
D. An error at line 2 caus 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. fal
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; 
         ca 10: 
            System.out.println("ten");
         ca 20: 
            System.out.println("twenty"); 
               break; 
       }
    }
}
A) None of the 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 enterpri rvice bus (ESB) is a pattern of middleware that unifies and connects rvices, 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 reu 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.
答案
第一部分 :JAVA语言基础(3*15=45)
1 G 2 D 3 BD 4 A 5 ABD 6 G 7 A 8 D 9 A 10 13423     
11 C 12 A 13 C 14 B 15 A
 
第二部分 :J2EE部份简答题(5*6=30)
 
1.简述J2EE Architecture。
要点:
a)         J2EE是使用Java技术开发企业级应用的一组标准规范:JSP/Servlet/JDBC/JMS XML/EJB/JSF/WebServices等;
b)         J2EE是一个分布的多层应用体系架构:客户端,Web层,业务层,数据层。
 
2.简述JSP在Web Container中的生命周期。
要点:
a)         当一个请求映射到一个Jsp页面时,由一个特殊的rvlet来处理,该rvlet首先检查一下对应的JSP页面有没有改动,如果有变动则将该JSP页面转换为rvlet类并编译这个类。
b)         一旦页面被解释并执行,JSP页面的rvlet的生命周期大部分与rvlet类似: 
                         i.              如果JSP页面的rvlet实例不存在,容器将:
1)        载入JSP的rvlet class
2)        实例化一个rvlet class
3)        通过调用jspInit 方法实例化rvlet
                        ii.              调用_jspService方法,传递请求及响应对象。
                      iii.              如果容器需要移除JSP页面的rvlet,就调用jspDestroy方法。
 
3.如何使用数据库连接池?有什么好处?

本文发布于:2023-06-19 10:37:24,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/990314.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:页面   应用   列举   模式   框架   过程   方法
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图