2024年计算机考试-Java认证笔试参考题库含答案_第1页
2024年计算机考试-Java认证笔试参考题库含答案_第2页
2024年计算机考试-Java认证笔试参考题库含答案_第3页
2024年计算机考试-Java认证笔试参考题库含答案_第4页
2024年计算机考试-Java认证笔试参考题库含答案_第5页
已阅读5页,还剩84页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

“人人文库”水印下载源文件后可一键去除,请放心下载!(图片大小可任意调节)2024年计算机考试-Java认证笔试参考题库含答案“人人文库”水印下载源文件后可一键去除,请放心下载!第1卷一.参考题库(共75题)1.现有:  1.class SuperFoo{  2.SuperFoo doStuff (int x)  {      3.return new SuperFoo();      4.    }      5.  }      6.  7. class Foo extends SuperFoo  {     8.    //insert code here     9.  }  和四个声明:   Foo doStuff (int x)  {  return new Foo();  }  Foo doStuff (int x)  {  return new SuperFoo();  }      SuperFoo doStuff(int x)  {  return new Foo();  }  SuperFoo doStuff(int y)  {  return new SuperFoo();  }    分别插入到第8行,有几个可以通过编泽?()    A、 1B、 2C、 3D、 42.When line 14 is reached, how many objects are eligible for the garbage collector?() A、0B、1C、2D、3E、4F、63.Which methods from the String and StringBuffer classes modify the object on which they are called?()  A、The charAt() method of the String class.B、The toUpperCase() method of the String class.C、The replace() method of the String class.D、The reverse() method of the StringBuffer class.E、The length() method of the StringBuffer class.4.11. public class Commander {  12. public static void main(String[] args) {  13. String myProp = /* insert code here */  14. System.out.println(myProp);  15. }  16. }  and the command line:  java -Dprop.custom=gobstopper Commander  Which two, placed on line 13, will produce the output gobstopper?()A、 System.load(”prop.custom”);B、 System.getenv(”prop.custom”);C、 Sperty(”prop.custom”);D、 System.getProperty(”prop.custom”);E、 System.getProperties().getProperty(”prop.custom”);5.定义一个表示学生信息的类Student,要求如下:   (1)类Student的成员变量:  sNO 表示学号;sName表示姓名;sSex表示性别;sAge表示年龄;sJava:表示Java课程成绩。  (2)类Student带参数的构造方法:   在构造方法中通过形参完成对成员变量的赋值操作。  (3)类Student的方法成员:  getNo():获得学号;   getName():获得姓名;   getSex():获得性别;  getAge()获得年龄;  getJava():获得Java 课程成绩  (4)根据类Student的定义,创建五个该类的对象,输出每个学生的信息,计算并输出这五个学生Java语言成绩的平均值,以及计算并输出他们Java语言成绩的最大值和最小值。6.现有如下类型:   a - java.util.Hashtable  b - java.util.List  c - java.util.ArrayList  d - java.util.SortedSet  和定义:  1 – 使用本接口,允许用户控制集合中每个元素的插入位置。   2 – 使用本集合,确保用户可以按照递增或元素的自然顺序遍历集合。   3 – 本具体类型允许空元素及基于索引的访问。    4 – 本集合是同步的。   哪一组匹配是对的?() A、 1 描述 b; 3 描述 c。B、 2 描述 d; 3 描述 b。C、 3 描述 a; 4 描述 b。D、 4 描述 a; 2 描述 c。7. Which statement at Point X on line 1 allows this code to compile and run?()A、 import java.io.*.;B、 include java.io.*;C、 import java.io.PrintWriter;D、 include java.io.PrintWRiter;E、 No statement in needed.8.如果不使用布局管理器,会出现哪些问题?()A、当界面缩放时,会失去原有的外观;B、当界面最小化时,组件不会最小化;C、当界面缩放时,组件会随机地移动;D、高分辨率下设计的界面,在低分辨率下可能会超出桌面范围,从面无法看到;E、对每一个组件,都需要指定它的坐标位置;9.Java SE JDK中类库java.text的用途是哪项?()A、工具类B、输出输入支持类C、文本处理和格式化类D、结构化查询语言(SQL)支持类10.下列叙述正确的是哪项?()A、事件继承模型取代事件委托模型B、事件继承模型比事件委托模型更加高效C、事件委托模型使用事件监听器来定义事件处理类的方法D、事件委托模型使用handleEvent()方法来支持事件处理11.Which two are true?()A、 An encapsulated, public class promotes re-use.B、 Classes that share the same interface are always tightly encapsulated.C、 An encapsulated class allows subclasses to overload methods, but does NOT allow overriding methods.D、 An encapsulated class allows a programmer to change an implementation without affecting outside code.12.A programmer needs to create a logging method that can accept an arbitrary number of arguments. For example, it may be called in these ways:  logIt(”log message 1 “);  logIt(”log message2”,”log message3”);  logIt(”log message4”, “log message5”, “log message6);  Which declaration satisfies this requirement?()A、 public void logIt(String * msgs)B、 public void logIt(String [] msgs)C、 public void logIt(String... msgs)D、 public void logIt(String msg1, String msg2, String msg3)13.输入一个字符串,其中包含数字、特殊符号(像:¥、&、(、>等)、大小写字母等,然后输出每个字符串或符号的ASCII码的和;例如:输入“@#$%^&*():"|”,则打印出643。14.Given the following code: What is the result()。A、The program prints”0”B、The program prints”4”C、The program prints”8”D、The program prints”12”E、The code does not complete.15.程序员已经创建了一个类,该类的实例可以用做Hashtable 的键(key)。哪两项是对的?()    A、该类有一个返回类型为 int 的 equals 方法。B、该类有一个返回类型为 boolean 的 equals 方法。C、该类有一个接收一个参数的 equals 方法。D、该类有一个接收两个参数的 equals 方法。16.System.out.println(Math.sqrt(-4D));  What is the result?()  A、 –2B、 NaNC、 InfinityD、 Compilation fails.E、 An exception is thrown at runtime.17.Which three code fragments, added individually at line 29, produce the output 100?() A、n = 100;B、i.setX(100);C、o.getY().setX(100);D、i = new Inner(); i.setX(100);E、o.setY(i); i = new Inner(); i.setX(100);F、i = new Inner(); i.setX(100); o.setY(i);18.爱因斯坦曾出过这样一道有趣的数学题:有一个长阶梯,每步上2阶,最后剩1阶;若每步上3阶,最后剩2阶;若每步上5阶,最后剩4阶;若每步上6阶,最后剩5阶;只有每步上7阶,最后一阶也不剩。请问该阶梯至少有多少阶。编写一个Java程序解决该问题。19.内存垃圾回收将删除无法访问的对象20.为了从文本文件中逐行读取内容,应该使用哪个处理流对象?()     A、 BufferedReaderB、 BufferedWriterC、 BufferedInputStreamD、 BufferedOutputStream21.现有:  public  class  TestDemo{     private int X-2;      static int y=3;  public  void method(){      final int i=100;      int j  =10;     class Cinner {  public void mymethod(){      //Here     }     }     }     } 在Here处可以访问的变量是哪些?() A、XB、yC、jD、i22.现有:  package mypack;  import javax.swing.JButton;      import javax.swing.JFrame;  public class Butt extends  JFrame  {     public static v.id main(string[]  args)  {      //  TODO Auto-generated method stub      Butt butt=new Butt();     }  Butt(){  JButton  jbl=new JButton("Hello");      JButton jb2=new JButton("World");      add(jbl);      add(jb2);  setSize(300,300);      setVisible(true);     }    } 下列关于代码运行效果的叙述正确的是哪项? ()   A、2个按钮紧靠着排列,Hello在World的左侧B、 Hello占据Frame的整个区域C、 World占据Frame的整个区域D、2个按钮都在Frame的顶部23.小程序的起始执行函数是什么?()   A、 init函数,用于初始化小程序B、 start函数,用于启动小程序C、 main函数,是入口函数D、 run函数,使小程序线程的启动函数24.什么是单例模式(Singleton)?请在下面写出一个单例模式类,并支持多线程调用。25.猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,还不瘾,又多吃了一个第二天早上又将剩下的桃子吃掉一半,又多吃了一个。以后每天早上都吃了前一天剩下的一半零一个。到第10天早上想再吃时,见只剩下一个桃子了。求第一天共摘了多少。26.class super (   public int I = 0;   public super (string text) (   I = 1   )   )   public class sub extends super (   public sub (string text) (   i= 2   )   public static void main (straing args) (  sub sub = new sub (“Hello”);   system.out. PrintIn(sub.i);  )   )   What is the result?()A、 Compilation will fail.B、 Compilation will succeed and the program will print “0”C、 Compilation will succeed and the program will print “1”D、 Compilation will succeed and the program will print “2”27.求能被3整除且至少有一位数字为5的三位数的个数28.import语句的作用是()A、导入包中成员B、创建包C、既可导入包成员,也可创建包D、访问控制29.public class Mycircle {   public double radius;   public double diameter;   public void setRadius(double radius)   this.radius = radius;   this.diameter= radius * 2;   }   public double getRadius() {  return radius;   }   Which statement is true?()  A、 The Mycircle class is fully encapsulated.B、 The diameter of a given MyCircle is guaranteed to be twice its radius.C、 Lines 6 and 7 should be in a synchronized block to ensure encapsulation.D、 The radius of a MyCircle object can be set without affecting its diameter.30.10. public class Hello {  11. String title;  12. int value;  13. public Hello() {  14. title += “ World”;  15. }  16. public Hello(int value) {  17. this.value = value;  18. title = “Hello”;  19. Hello();  20. }  21. }  and:  30. Hello c = new Hello(5);  31. System.out.println(c.title);  What is the result?() A、 HelloB、 Hello WorldC、 Compilation fails.D、 Hello World 5E、 The code runs with no output.F、 An exception is thrown at runtime.31.10. class Line {  11. public class Point { public int x,y; }  12. public Point getPoint() { return new Point(); }  13. }  14. class Triangle {  15. public Triangle() {  16. // insert code here  17. }  18. }  Which code, inserted at line 16, correctly retrieves a local instance of a Point object?() A、 Point p = Line.getPoint();B、 Line.Point p = Line.getPoint();C、 Point p = (new Line()).getPoint();D、 Line.Point p = (new Line()).getPoint();32.下列关于容器集合类的说法正确的是()。A、LinkedList继承自ListB、AbstractSet继承自SetC、HashSet继承自AbstractSeD、WeakMap继承自HashMap33.What is the resultasfollows?() A、5,6B、5,5C、6,5D、6,634.现有代码片段:      String  s="123";      String sl=S+456;  请问sl的结果是哪项?()     A、 123456B、 579C、编译错误D、运行时抛出异常35.class Foo {  public static void main(String [] args) {  int x = 0;  int y = 4;  for(int z=0; z 〈 3; z++, x++) {  if(x 〉 1 & ++y 〈 10) y++;  }  System.out.println(y);  }  }  结果是什么?()  A、6B、7C、8D、1036.java语言中int类型数据占用多少位()A、 32B、 64C、 16D、 2037.What is the result?() A、A,B,CB、B,C,AC、Compilation fails.D、The code runs with no outputE、An exception is thrown at runtime.38.class WhileTests { public static void main(String [] args) {  int x = 5;  while (++x 〈 3) {  --x;  }  System.out.println("x = " + x);  }  } 结果是什么?()A、x = 2B、x = 5C、x = 6D、编译失败39.What is the result when method testIfA is invoked?() A、TrueB、Not trueC、An exception is thrown at runtime.D、Compilation fails because of an error at line 12.E、Compilation fails because of an error at line 19.40.Given that login.getName() returns a java.lang.String value and given the JSP code:  Welcome Which is equivalent?()A、 Welcome  B、 Welcome  C、 Welcome D、 Welcome  E、 Welcome 41.publicclassTest{ publicstaticvoidmain(String[]args){ intx=5; booleanb1=true; booleanb2=false; if((x==4)&&!b2) System.out.print("l"); System.out.print("2"); if((b2=true)&&b1) System.out.print("3"); } } Whatistheresult?()A、2B、3C、12D、23E、123F、Compilationfails.G、Anexceptionalisthrownatruntime.42.辗转相除法:从键盘输入两个数51211314和84131421,利用辗转相除法求它们的最大公约数。求需要经过多少次辗转43.What is the result?() A、The code will deadlock.B、The code may run with no output.C、An exception is thrown at runtime.D、The code may run with output "0 6".E、The code may run with output "2 0 6 4".F、The code may run with output "0 2 4 6".44.完成数组int[]a={100,40,60,87,34,11,56,0}的快速排序、冒泡排序45.Which interface does java.util.Hashtable implement?()  A、 java.util.MapB、 java.util.ListC、 java.util.HashableD、 java.util.Collection46.(1)编写一个圆类Circle,该类拥有:  ①一个成员变量  Radius(私有,浮点型);  // 存放圆的半径;  ②两个构造方法            Circle( )                 // 将半径设为0            Circle(double  r )         //创建Circle对象时将半径初始化为r         ③ 三个成员方法              double getArea( )       //获取圆的面积              double getPerimeter( )   //获取圆的周长              void  show( )          //将圆的半径、周长、面积输出到屏幕  (2)编写一个圆柱体类Cylinder,它继承于上面的Circle类。还拥有:  ①一个成员变量  double hight(私有,浮点型);  // 圆柱体的高;  ②构造方法            Cylinder (double r, double  h )           //创建Circle对象时将半径初始化为r  ③ 成员方法              double getVolume( )             //获取圆柱体的体积              void  showVolume( )             //将圆柱体的体积输出到屏幕  编写应用程序,创建类的对象,分别设置圆的半径、圆柱体的高,计算并分别显示圆半径、圆面积、圆周长,圆柱体的体积。47.For which three events can web application event listeners be registered? ()A、 when a session is createdB、 after a servlet is destroyedC、 when a session has timed outD、 when a cookie has been createdE、 when a servlet has forwarded a requestF、 when a session attribute value is changed48.Click the ’Select and Place’ button. Place the events in the order they occur. 49.以下关于File 类的叙述,哪两项正确?()A、File 类位于java.io 包中B、创建一个File 类的实例将导致打开指定文件进行读写C、File 实例封装了指定文件的信息D、File 实例不能用于封装目录50.求表达式e^x≈1+x+x^2/2!+x^3/3!+x^4/4!……+x^n/n!的近似值,设x=9,n=2551.11. double input = 314159.26;  12. NumberFormat nf= NumberFormat.getInstance(Locale.ITALIAN);  13. String b;  14. //insert code here  Which code, inserted at line 14, sets the value of b to 3 14.159,26?() A、 b = nf.parse( input);B、 b = nf.format( input);C、 b = nf.equals( input);D、 b = nf.parseObject( input);52.在类的继承中,构造函数如何处理?()A、子类的构造函数覆盖父类的构造函数B、以父类的构造函数为准,子类没有自己的构造函数C、先执行父类的构造函数,再执行子类的构造函数D、如果父类的构造函数带参数,则子类必须在构造函数的开头用super()显式地调用父类的构造函数E、除非子类在够在函数中用super()显式地调用,否则不会执行父类的构造函数53.class Wrench {  public static void main(String [] args) {  Wrench w = new Wrench(); Wrench w2 = new Wrench();  w2 = go(w,w2);  System.out.print(w2 == w);  }  static Wrench go(Wrench wr1, Wrench wr2) {  Wrench wr3 = wr1; wr1 = wr2; wr2 = wr3;  return wr3; }  }  结果是什么?() A、trueB、falseC、编译失败D、输出不可预期54.求满足以下条件的(a,b,c)的组数: (1)1/(a^2)+1/(b^2)=1/(c^2) (2)a>b>c (3)a+b+c<10055.class Ifs{   public static void main(String[] args){   boolean state=false;   int i=1;   if((++i>1)&&(state=true))   i++;   System.out.println(i);  }  } 结果是()  A、5B、编译失败C、运行时异常被抛出D、3E、456.输入两个正整数m和n,求其最大公约数和最小公倍数。57.同一个包的子类能否访问父类的保护级成员变量?()A、可以访问B、不能访问C、可以访问,但不能从父类中继承保护级成员D、不能访问,但可以从父类中继承保存级成员58.已知: 下面哪些语句是和第2行等价的()A、publicinti=1;B、staticinti=1;C、finalinti=1;D、abstractinti=1;59.客户端C和服务器S之间建立一个TCP连接,该连接总是以1KB的最大段长发送TCP段,客户端C有足够的数据要发送。当拥塞窗口为16KB的时候发生超时,如果接下来的4个RTT往返时间内的TCP段的传输是成功的,那么当第4个RTT时间内发送的所有TCP段都得到了ACK时,拥塞窗口大小是()。A、7KBB、8KBC、9KBD、16KB60.Under what two circumstances is the set JspBody method NOT called in a tag class that implements the Simple Tag interface? ()A、 The tag is invoked without a body.B、 The doTAb method throws an exception.C、 The  element has the value empty.D、 The tag is called with the attribute skip-body=true61.Given a class Repetition:  1. package utils;  2.  3. public class Repetition {  4. public static String twice(String s) { return s + s; }  5. }  and given another class Demo:  1. // insert code here 2.  3. public class Demo {  4. public static void main(String[] args) {  5. System.out.println(twice(”pizza”));  6. }  7. }  Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?() A、 import utils.*;B、 static import utils.*;C、 import utils.Repetition.*;D、 static import utils.Repetition. *;E、 import utils.Repetition.twice();F、 import static utils.Repetition.twice;G、 static import utils.Repetition.twice;62.设计一个汽车类Multiplication,在其中定义三个同名的mul方法:第一个方法是计算两个整数的积;第二个方法是计算两个浮点数的积;第三个方法是计算三个浮点数的积。63.public class ItemTest {  private final mt id;  public ItemTest(int id) { this.id = id; }  public void updateId(int newId) { id = newId; }  public static void main(String[] args) {  ItemTest fa = new ItemTest(42);  fa.updateId(69);  System.out.println(fa.id);  }  }  What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 The attribute id in the Item object remains unchanged.D、 The attribute id in the Item object is modified to the new value.E、 A new Item object is created with the preferred value in the id attribute.64.You need to retrieve the username cookie from an HTTP request. If this cookie does NOT exist, then the cvariable will be null. Which code snippet must be used to retrieve this cookie object?()A、B、C、D、65.两个字符串连接程序66.Public class test (    Public static void stringReplace (String text) (    Text = text.replace („j„ , „i„);    )      public static void bufferReplace (StringBuffer text) (    text = text.append (“C”)   )      public static void main (String args ){  String textString = new String (“java”);    StringBuffer text BufferString = new StringBuffer (“java”);      stringReplace (textString);    BufferReplace (textBuffer);      System.out.printIn (textString + textBuffer);    }   )   What is the output?()67.什么是方法的覆盖?方法的覆盖与域的隐藏有何不同?与方法的重载有何不同?68.Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here26. } Which should you insert at line 25 to properly invoke the next filter in the chain,or the target servlet if thereare no more filters?()A、chain.forward(request, response);B、chain.doFilter(request, response);C、request.forward(request, response);D、request.doFilter(request, response);69.下面关于try、catch和finally语句块的组合使用,正确的是()A、try{,}B、try{,}finally{,}C、try{,}catch{,}finally{,}D、try{,}catch{,}catch{,}70.A custom JSP tag must be able to support an arbitrary number of attributes whose names are unknown when the tag class is designed.  Which two are true? ()A、 A  element in the echo tag LTD must have the value JSPB、 The echo tag handler must define the setAttribute (String key, String value) methodC、 The true element must appear in the echo tag TLDD、 The class implementing the echo tag handler must implement the javax.sevlet.jsp.tagext.IterationTag interfaceE、 The class implementing the echo tag handler must implement the javax.sevlet.jsp.tagext.DynamicAttributes interface71.输入年份和月份即可打印出当月的日历72.已知: 下面哪些代码是正确的?()A、B、C、D、73.Within a web application deployment descriptor, which maps the com.example.LoginServlet servlet to /utils/LoginServlet?() A、AB、BC、CD、D74.在Swing GUI编程中,setDefaultCloseOperation(JFrame.EXIT_ON_ CLOSE)语句的作用是:() A、当执行关闭窗口操作时,不做任何操作。B、当执行关闭窗口操作时,调用WindowsListener对象并将隐藏JFrameC、当执行关闭窗口操作时,退出应用程序D、当执行关闭窗口操作时,调用WincowsListener对象并隐藏和销毁Jframe75.线程安全的map在JDK1.5及其更高版本环境有哪几种方法可以实现()。A、Map map = new HashMap()B、Map map = new TreeMap()C、Map map = new ConcurrentHashMap()D、Map map = Collections.synchronizedMap(new HashMap())第2卷一.参考题库(共75题)1.public class MethodOver {  private int x, y;  private float z;  public void setVar(int a, int b, float c){  x = a;  y = b;  z = c;  }  }   Which two overload the setVar method?()   A、  void setVar (int a, int b, float c){ x = a; y = b; z = c; }B、 public void setVar(int a, float c, int b) { setVar(a, b, c); }C、 public void setVar(int a, float c, int b) { this(a, b, c); }D、 public void setVar(int a, float b){ x = a; z = b; }E、 public void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }2.Which Man class properly represents the relationship “Man has a best friend who is a Dog”?() A、 class Man extends Dog { }B、 class Man implements Dog { }C、 class Man { private BestFriend dog; }D、 class Man { private Dog bestFriend; }E、 class Man { private Dog }F、 class Man { private BestFriend }3.通过Ajax,客户端获取的数据主要有两种类型:文本型和()4.打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。5.1. import java.util.*;  2. class SubGen {  3. public static void main(String [] args) {  4. //insert code here  5. }  6. }  class Alpha { }  class Beta extends Alpha { }  class Gamma extends Beta { }  和四段代码片段:  s1. ArrayList〈? extends Alpha〉 list1 = new ArrayList〈Gamma〉();  s2. ArrayList〈Alpha〉 list2 = new ArrayList〈? extends Alpha〉();  s3. ArrayList〈? extends Alpha〉 list3 = new ArrayList〈? extends Beta〉();  s4. ArrayList〈? extends Beta〉 list4 = new ArrayList〈Gamma〉(); ArrayList〈? extends Alpha〉 list5 = list4;  哪些片段分别插入到第4行,可允许代码编译?()  A、只有s1B、只有s3C、只有s1和s3D、只有s1和s46.A collection of products is stored in the Servle Context in an attribute called catalog.  Which JSTL code structure iterated over each product in the collection and prints out the names of the products in an un-ordered list?() A、AB、BC、CD、D7.判断一个整数能被几个9整除8.public class TestApp{  public static void main(String[] args){       try{  int i = 0;           int j = 1 / i;           String myname=null;            if(myname.length()>2)              System.out.print(“1”);        }catch(NullPointerException e){  System.out.print(“2”);       }  catch(Exception e){  System.out.print(“3”);       }   } }  上述程序运行后的输出是哪项?()A、 3B、 2C、 231D、 329.已知: 则输出为()A、81B、11C、7D、010.public class test(  public static void main(string[]args){  string foo = args [1];  string foo = args [2];  string foo = args [3];  }  )  And command line invocation: Java Test red green blue   What is the result?()  A、 Baz has the value of “”B、 Baz has the value of nullC、 Baz has the value of “red”D、 Baz has the value of “blue”E、 Bax has the value of “green”F、 The program throws an exception.11.Which are not Java keywords? ()   A、 TRUEB、 sizeofC、 constD、 superE、 void12.float f[][][] = new float[3][][];  float f0 = 1.0f;  float[][] farray = new float[1][1];  What is valid?()  A、 f[0] = f0;B、 f[0] = farray;C、 f[0] = farray[0];D、 f[0] = farray[0][0];13.What is the result?() A、Compilation fails.B、After line 15, the value of age is 5.C、After line 15, the value of age is 3.D、An exception is thrown at runtime.14.现有如下五个声明:  Linel: int a_really_really_really_long_variable_name=5 ;     Line2: int  _hi=6;  Line3:  int  big=Integer. getlnteger("7”);      Line4:int $dollars=8;      line5: int %opercent=9;      哪行无法通过编译?()A、Line1B、Line3C、Line4D、Line515.把一张一元钞票,换成一分、二分和五分硬币,每种至少8枚,求方案数16.byte arry1, array2;   byte array3 ;   byte array4;   If each array has been initialized, which statement will cause a compiler error?()A、 Array2 = array1;B、 Array2 = array3;C、 Array2 = array4;D、 Both A and BE、 Both A and CF、 Both B and C17.将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。 程序分析:对n进行分解质因数,应先找到一个最小的质数k,然后按下述步骤完成:     (1)如果这个质数恰等于n,则说明分解质因数的过程已经结束,打印出即可。     (2)如果n  k,但n能被k整除,则应打印出k的值,并用n除以k的商,作为新的正整数你n,重复执行第一步。     (3)如果n不能被k整除,则用k+1作为k的值,重复执行第一步。18.在类Acoount中,正确引入类school.Student的语句是哪一项?()  A、import schoolB、import schllo.*C、package school.StudentD、import Student19. 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;}20.为了使得System.out.println()输出对象引用的时候得到有意义的信息,我们应该覆盖Object中的哪个方法?() A、 equalsB、 hashCodeC、 toStringD、 notify21.下列叙述正确的是哪项?()  A、TextField能产生ActionEvent事件B、TextArea能产乍ActionEvent事件C、Button能产牛ActionEvent事件D、Menultem能产生ActionEvent事件22.写一个类,并在一个方法抛出一个异常。试着在没有异常规范的前提下编译它,观察编译器会报告什么。接着添加适当的异常规范。在一个try-catch从句中尝试自己的类以及它的异常。23.If class Donkey2 is invoked twice, the first time without assertions enabled, and the second time with assertions enabled, what are the results?() A、no outputB、no output assert is onC、assert is onD、no output , An Assertion Error is thrown.E、assert is on , An AssertionError is thrown.24. What is the result?()A、 the program runs and prints nothing.B、 The program runs and prints “Finally”.C、 The code compiles. But an exception is thrown at runtime.D、 the code will not compile because the catch block is missing.25.public class Yippee {  public static void main(String [] args) {  for(int x = 1; x A、 No output is produced. 123B、 No output is produced. 234C、 No output is produced. 1234D、 An exception is thrown at runtime. 123E、 An exception is thrown at runtime. 234F、 An exception is thrown at rijntime. 123426.回文数是指正读和反读都一样的正整数  例如3773是回文数。求[1000,9999]之间的奇数回文数的个数27.Which will declare a method that is available to all members of the same package and can be referenced  without an instance of the class?()  A、 Abstract public void methoda();B、 Public abstract double methoda();C、 Static void methoda(double d1){}D、 Public native double methoda(){}E、 Protected void methoda(double d1){}28.如果一个方法或变量是"private"访问级别,那么它的访问范围是:()。A、在当前类,或者子类中B、在当前类或者它的父类中C、在当前类,或者它所有的父类中D、在当前类中29.public class TestApp{  public static void main(String[] args){        try{  int i = 0;           int j = 1 / i;  System.out.println(“1”);        }catch(Exception e){              System.out.print(“3”);       }finally{  System.out.print(“4”);       }   } }  上述程序运行后的输出是哪项?() A、 4B、 34C、 43D、 1430.One of the use cases in your web application uses many session-scoped attributes. At the end of the usecase,you want to clear out this set of attributes from the session object. Assume that this static variableholds this set of attribute names: 201.private static final Set USE_CASE_ATTRS;  202.static { 203.USE_CASE_ATTRS.add("customerOID"); 204.USE_CASE_ATTRS.add("custMgrBean"); 205.USE_CASE_ATTRS.add("orderOID"); 206.USE_CASE_ATTRS.add("orderMgrBean"); 207.} Which code snippet deletes these attributes from the session object?()A、session.removeAll(USE_CASE_ATTRS);B、for ( String attr : USE_CASE_ATTRS ) {session.remove(attr);}C、for ( String attr : USE_CASE_ATTRS ) {session.removeAttribute(attr);}D、for ( String attr : USE_CASE_ATTRS ) {session.deleteAttribute(attr);}E、session.deleteAllAttributes(USE_CASE_ATTRS);31.在linux编程中,以下哪个TCP的套接字选项与nagle算法的开启和关闭有关()。A、TCP_MAXSEGB、TCP_NODELAYC、TCP_SYNCNTD、TCP_KEEPALIVE32.Which statements are true concerning the default layout manager for containers in the java.awt package?()  A、Objects instantiated from Panel do not have a default layout manager.B、Objects instantiated from Panel have FlowLayout as default layout manager.C、Objects instantiated from Applet have BorderLayout as default layout manager.D、Objects instantiated from Dialog have BorderLayout as default layout manager.E、Objects instantiated from Window have the same default layout manager as instances of Applet.33.How can you force garbage collection of an object?()A、 Garbage collection cannot be forced.B、 Call System.gc().C、 Call System.gc(), passing in a reference to the object to be garbage collected.D、 Call Runtime.gc().E、 Set all references to the object to new values(null, for example).34.试列举出图形用户界面中你使用过的组件。35.求数列f(n)=n

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论