北京神舟航天软件笔试题

时间:2020-07-20 10:35:10 笔试题目 我要投稿

北京神舟航天软件笔试题

  Java笔试试题

北京神舟航天软件笔试题

  基础篇(100分钟)(满分100分)

  (一) 不定项选择题(36分,每小题1.5分)

  基本语法测试

  1.给定如下代码

  class Test{

  private int m;

  public static void fun() {

  // some code...

  }

  }

  怎样修改才能使变量m能够在方法fun()中直接使用

  A.改成protected int m

  B. 改成public int m

  C. 改成static int m

  D. 改成int m to int m

  2.下面的方法中那个是public void example(){...}的正确的重载函数(JDK1.4)

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

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

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

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

  3.给出如下定义

  String s = "story";

  下面的表达式中那个是正确的?

  A. s += "books";

  B. char c = s[1];

  C. int len = s.length;//没有()

  D. String t = s.toLowerCase();

  4.给定如下代码段:

  boolean m = false;

  if ( m = false )

  System.out.println("False");

  else

  System.out.println("True");

  其运行结果是什么?

  A. False

  B. True

  C. None

  D. 有错误,无法编译通过.

  5. 所给代码如下:

  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) }

  17) }

  该代码会在那一行出错?

  A. line 3

  B. line 6

  C. line 10

  D. line 14

  E. line 15

  6. 下面那种描述是正确的?

  A. 在Java中不允许多重继承,这样可以使程序更加可靠

  B. 子类继承父类的所有方法 (包括构造方法)

  C. 一个类可以实现很多接口.

  D. 当一个类实现一个接口,那么他就必须定义该接口中的所有方法。

  7. 下面关于final、finally、finalize描述正确的是

  A. final可以被用来做常量的定义关键字

  B. finally可以被用作类限定词

  C. finalize可以被用来进行错误处理

  D. final可以被用来作为垃圾回收的回调函数

  E. final可以被用来作为一个抽象函数的限定词,如: public final abstract fun();

  8. 下面关于String描述正确的.是:

  A. String str1=”aa”; String str2=”aa”; System.out.println((str1==str2)); 输出为true

  B. String str1=”aa”; String str2=”aa”; System.out.println(str1.equals(str2)); 输出为true

  C. String str1 = “aaaa” + “bbbbb” + “aaaa”; 会产生5个对象

  D. String aaa = “aaaaaa[dd”.replaceAll(“[“, “c”); aaa的值变为”aaaaaacdd”

  IO方面API测试

  9. 下面哪些Java中的流对象是字节流?

  A. FileInputStream B. BufferedInputStream

  C. PushbackInputStream D. ByteArrayInputStream

  10. 下面的类哪些可以处理Unicode字符?

  A. InputStreamReader

  B. BufferedReader

  C. Writer

  D. PipedInputStream

  Java异常处理

  11. 下面程序的输出结果是什么

  class TestException{

  public static void main( String[] args ){

  int i = 0;

  try {

  if (i == 0) {

  throw new IOException("IO Error");

  }

  } catch (IOException ioex) {

  System.out.print(ioex.getMessage());

  i++;

  } catch (Exception ex) {

  System.out.print("Exception Find") ;

  i += 2;

  } finally {

  i++;

  }

  try {

  if (i == 1) {

  throw new IOException("IO Error");

  }

  if (i == 2) {

  throw new Exception("Exception Find");

  } else {

  throw new Error( "Unknow Error" ) ;

  }

  } catch( IOException ex ){

  System.out.print(ex.getMessage());

  } catch (Exception ex) {

  System.out.print(ex.getMessage());

  } catch (Throwable tr){

  System.out.print(tr.getMessage());

  }

  }

  }

  A. IO ErrorIO Error

  B. IO ErrorUnknow Error

  C. IO ErrorException Find

  D. Exception FindIO Error

  E. Exception FindException Find

  Java多线程测试

  12. 如果一个线程调用了wait(), 那个方法可以让他继续运行?

  A. join()

  B. resume()

  C. notify()

  D. notifyAll()

  E. high priority thread is ready

  13. 下面那个方法被用来定义线程的执行体?

  A. start()

  B. init()

  C. run()

  D. main()

  E. synchronized()

  14. 下面那个关键字用于对线程进行互斥访问控制?

  A. native

  B. static

  C. synchronized

  D. abstract

  数据结构API

  15. 下面那个Java中的类可以用来保存数据时随机访问效率较高

  A. ArrayList B. Vector C.LinkList D.Stack

  16. 下面那个Java类中可以用来用来保存键值对

  A. HashSet B. HashMap C.LinkList D.Stack

  Swing开发测试

  17. 下面那个容器对象必须要添加到其他的容器对象中才能使用?

  A. Window

  B. Frame

  C. Dialog

  D. Panel

  18. 下面哪些类是Java中的布局管理器?

  A. CardLayout

  B. BorderLayout

  C. PanelLayout

  D. GridLayout

  E. BagLayout

  19. 将一个Button放置到一个Frame中,使这个Button的高随着Frame的改变而改变,但是宽度不随之改变,应该采用哪种布局方式?

  A. FlowLayout

  B. CardLayout

  C. North and South of BorderLayout

  D. East and West of BorderLayout

  E. GridLayout

  20. 下面哪些方法能够在类EventObject中得到事件源?

  A. getFrame() B. getID()

  C. getSource() D. getWindow()

  21. 下面那个关于事件探听器的描述是正确的?

  A. 一个组件可以注册多个事件探听器.

  B. 一个组件只能注册一个事件探听器.

  C. 一个探听器可以接收和处理来自多个组件的事件.

  D. 一个探听器只能接收和处理来自一个组件的事件.

  22. 下面的类哪些不是Java中的容器类?

  A. ScrollPane

  B. JLabel

  C. Scrollbar

  D. Dialog

  网络通讯测试

  23. 下面的类中哪些被用来实现Tcp/Ip协议的客户端和服务器端程序?

  A. ServerSocket

  B. Server

  C. Socket

  D. DatagramPacket

  E. DatagramSocket

  24. 下面关于TCP和UDP的描述正确的是:

  A. TCP连接发送数据之前必须保证网络连接已经成功建立

  B. UDP连接发送数据之前必须保证网络连接已经成功建立

  C. ServerSocket类建立的是TCP连接

  D. DatagramSocket类建立的是UDP连接

  (二) 问答题(34分)

  数据库基础知识

  1、 分别写出数据库逻辑结构中各种不同对象的作用(表,视图,序列,存储过程,索引,主键,外键,约束,触发器)(10分)

  SQL问答题

  2、 根据要求写出Sql查询语句(10分)

  表结构:

  1、 表名:g_cardapply

  字段(字段名/类型/长度):

  g_applyno varchar 8;// 申请 单号(关键字)

  g_applydate bigint 8;//申请日期

  g_state varchar 2;//申请状态

  2、 表名:g_cardapplydetail

  字段(字段名/类型/长度):

  g_applyno varchar 8;//申请单号(关键字)

  g_name varchar 30;//申请人姓名

  g_idcard varchar 18;//申请人身份证号

  g_state varchar 2;//申请状态

  其中,两个表的关联字段为申请单号。

  题目:

  1、 查询身份证号码为440401430103082的申请日期

  Select applay. g_applydate

  From g_cardapply applay, g_cardapplydetail detail

  Where applay. g_applyno=detail. g_applyno

  And detail. g_idcard=’ 440401430103082’

  2、 将身份证号码为440401430103082的记录在两个表中的申请状态均改为07

  Update g_cardapply apply, g_cardapplydetail detail set applay.g_state=’07’, detail.g_state=’07’ Where applay. g_applyno=detail. g_applyno

  And detail. g_idcard=’ 440401430103082’

  3、 删除g_cardapplydetail表中所有姓李的记录

  Delete from g_cardapplydetail where g_name like ‘李%’

  Java API运用

  3、 请写出你所知道的Java API中所提供的数据结构模型(例如Vector),并指出各数据模型在存储结构上和使用上有什么不同。(7分)

  4、 指出JDBC中三种不同类型的Statement(Statement、PreparedStatement、CallableStatement)的用途分别是什么。(7分)

  (三) 读程序写结果(10分)

  写出下面程序的运行结果,下面程序有些可能根本无法通过编译,如果无法编译通过,请指出错误原因。

  1、写出下面程序的运行结果:(3分)

  public class Test {

  public static void changeStr(String str){

  str="welcome";

  }

  public static void main(String[] args) {

  String str="1234";

  changeStr(str);

  System.out.println(str);

  }

  }

  2、写出下面程序的运行结果(5分)

  class Foo{

  public static void main(String args[]){

  int x=4,j=0;

  switch(x){

  case 1:j++;

  case 2:j++;

  case 3:j++;

  case 4:j++;

  case 5:j++;

  default:j++;

  }

  System.out.println(j);

  }

  }

  (四) 代码查错(10分)

  1、指出下面程序的运行错误(4分)

  public class OutClass{

  private int varInOuterClass = 0;

  public OutClass(){

  }

  public void callOutter(){

  int varInOuterMethod = 0;

  class InnerClass{

  private int varInInnerClass = 0;

  public InnerClass(){

  }

  public void print(){

  System.out.println("varInOuterClass" + varInOuterClass);

  System.out.println("varInInnerClass" + varInInnerClass);

  System.out.println("varInInnerClass" + varInOuterMethod);

  }

  }

  InnerClass inner = new InnerClass();

  inner.print();

  }

  public static void main(String[] args){

  OutClass out = new OutClass();

  out.callOutter();

  }

  }

  2、指出下面程序的运行错误(3分)

  public class Something {

  public static void main(String[] args) {

  Something s = new Something();

  System.out.println("s.doSomething() returns " + doSomething());

  }

  public String doSomething() {

  return "Do something ...";

  }

  }

  (五) 编程题(10分)

  算法设计能力测试(10分)

  1、编写一个类,该类封装了一元二次方程共有的属性和功能,即该类有刻画方程系数的3个成员变量以及计算实根的方法。

  方程: 求根方法为 要求:该类的所有对象共享常数项。

  下面给出了您在程序中可能会使用到的功能类,及其部分接口的API文档,在程序中可以进行使用,

java.lang.Math      
staticfloat      signum(floatf)
       Returns the signum function of the argument; zero if the argument is zero, 1.0f if the argument is greater than zero, -1.0f if the argument is less than zero.
staticdouble      sin(doublea)
       Returns the trigonometric sine of an angle.
staticdouble      sinh(doublex)
       Returns the hyperbolic sine of a double value.
staticdouble      sqrt(doublea)
       Returns the correctly rounded positive square root of a double value.
staticdouble      tan(doublea)
       Returns the trigonometric tangent of an angle.
staticdouble      tanh(doublex)
       Returns the hyperbolic tangent of a double value.
staticdouble      toDegrees(doubleangrad)
       Converts an angle measured in radians to an approximately equivalent angle measured in degrees.
staticdouble      toRadians(doubleangdeg)
       Converts an angle measured in degrees to an approximately equivalent angle measured in radians.

  参考答案

  (一)不定项选择

  1, C 2, A D 3, A D 4, B 5, E 6, A C D 7, A E 8, A B 9, A B C D

  10, A B C 11, C 12, C D 13, C 14, C 15, C 16, B 17, D, 18, A B D

  19, D, 20, C D 21,B C 22, B C 23, A C E 24, A C D

  (五)编程题

  public class Equation {

  public float a;

  public float b;

  public float c;

  public double[] d;

  public Equation(float a, float b, float c) {

  this.a = a;

  this.b = b;

  this.c = c;

  this.d = new double[2];

  }

  boolean getRealRoot() {

  float temp = b * b - 4 * a * c;

  if (temp < 0)

  return false;

  else {

  this.d[0] = (-b + Math.sqrt(temp)) / (2 * a);

  this.d[1] = (-b - Math.sqrt(temp)) / (2 * a);

  return true;

  }

  }

  public static void main(String[] arg) {

  Equation e1 = new Equation(1, 2, 1);

  if (e1.getRealRoot()) {

  System.out.print(e1.d[0]);

  System.out.print(";");

  System.out.println(e1.d[1]);

  } else {

  System.out.print("no real root");

  }

  }

  }

【北京神舟航天软件笔试题】相关文章:

360笔试题目07-11

华为2017笔试题08-16

华为2017笔试试题08-10

桂林银行笔试题笔经07-20

软件测试常见笔试题08-23

群硕软件笔试题07-11

北京航空航天大学就业情况10-06

名人故事:神舟十一号航天员景海鹏最初的梦想12-13

航天型号软件配置管理工作浅析论文06-29

2017软件测试面试题06-13