• 工作总结
  • 工作计划
  • 心得体会
  • 述职报告
  • 事迹材料
  • 申请书
  • 作文大全
  • 读后感
  • 调查报告
  • 励志歌曲
  • 请假条
  • 创先争优
  • 毕业实习
  • 财神节
  • 高中主题
  • 小学一年
  • 名人名言
  • 财务工作
  • 小说/有
  • 承揽合同
  • 寒假计划
  • 外贸信函
  • 励志电影
  • 个人写作
  • 其它相关
  • 生活常识
  • 安全稳定
  • 心情短语
  • 爱情短信
  • 工会工作
  • 小学五年
  • 金融类工
  • 搞笑短信
  • 医务工作
  • 党团工作
  • 党校学习
  • 学习体会
  • 下半年工
  • 买卖合同
  • qq空间
  • 食品广告
  • 办公室工
  • 保险合同
  • 儿童英语
  • 软件下载
  • 广告合同
  • 服装广告
  • 学生会工
  • 文明礼仪
  • 农村工作
  • 人大政协
  • 创意广告
  • 您现在的位置:六七范文网 > 其它相关 > 正文

    java,面试题

    来源:六七范文网 时间:2021-06-29 07:08:52 点击:

     java 面试题大全

     本套题目要紧出自神州数码, 华为, 笔试考试题以及 SCJP 认证考题

     一, 选择题 1. 以下数组初始化正确的选项是:C A int[5] a= {1,2,3,4,5}; B int[2][2] a = {{1,2},{3,4}}; C int[][] a = {{2,3,4,5},new int[3]}; D int[][] a = new int[][5];

     2. 下面的程序名为 Student.java:B public class Student { private String name; public Student(String s_name)

     //1 { name = s_name;

      //2 }

     public static void main(String args[]) { Student s = new Student();

      //3 } } 使用如下指令编译:

     javac Student.java 将会得到什么结果? A. 将会顺利通过编译,并将产生一个 Student.class 的类文件。

     B. 编译时在//3 处出错。

     C. 编译时在//2 处出错。

     D. 编译时在//1 处出错。

     3. 关于下述程序:C public class Divide { public static void main(String args[]) { System.out.println(""17.0/0 = ""+17.0/0);

     //1 System.out.println(""17/0 = ""+17/0);

      //2 } } 描述正确的选项是? A. 编译出错

     B. 编译通过,运行时//1、//2 处均显现专门 C. 编译通过,运行时//1 处得到一个无穷大值,//2 处将显现专门 D. 编译通过,运行时//1 处显现专门,//2 处将得到一个无穷大值

     4. 有下面程序:B public class TestString {

     public static void main(String[] args) {

     String str1 = 〝abcd〞;

     String str2 = 〝abcd〞;

     String str3 = new String(〝abcd〞);

     String str4 = new String(〝abcd〞);

     System.out.println(str1==str2);

     System.out.println(str3==str4); } } 输出结果是? A true

     true

      B true

     false

      C false

     true

      D false

     false

     5. 关于下面的类描述中正确的选项是:C class Test {

     void test(int i) {

     System.out.println(""I am an int."");

     }

     void test(String s) {

      System.out.println(""I am a string."");

     }

     public static void main(String args[]) {

     Test t=new Test();

      char ch="y";

     t.test(ch);

      }

     }

      A. 编译出错 B. 编译通过,运行出错 C. 编译通过,运行时输出〝I am an int〞 D. 编译通过,运行时输出〝I am a string〞

     6. 如期望父类中的某成员变量能被任何包中的子类直截了当访问,那么定义该变量时使用限定词____最适合。C A. public

      B private

     C protected

      D. default

     7. 当编译和运行以下程序段时,会发生什么? C

      class Base {}

     class Sub extends Base {}

     class Sub2 extends Base {}

     public class CEx{

      public static void main(String argv[]){

      Base b = new Base();

      Sub s = (Sub) b;

      }

     }

      A 通过编译和并正常运行。

     B 编译时显现错误。

      C 编译通过,运行时显现专门。

     D 以上都错

     8. 下面正确的选项是:

     A A 在 Java 中类只承诺单一继承 B 在 Java 中一个类只承诺实现一个接口 C 在 Java 中类不能同时继承一个类和实现一个接口 D 在 Java 中一个接口只能继承一个接口

     9. 下面哪些是 java 语言中的关键字? B

      A sizeof

      B abstract

      C NULL

      D Native

      10. 下面语句哪个是正确的? D

      A char c="ab";

      B int l=0xfffL;

      C float f=0.23;

      D double d=0.7E-3;

      11. class ExSuper{

      String name;

      String nick_name;

      public ExSuper(String s,String t){

     name = s;

      nick_name = t;

      }

     public String toString(){

      return name;

     }

      }

      public class Example extends ExSuper{

     public Example(String s,String t){

     super(s,t);

     }

     public String toString(){

      return name +""a.k.a""+nick_name;

      }

     public static void main(String args[]){

     ExSuper a = new ExSuper(""First"",""1st"");

     ExSuper b = new Example(""Second"",""2nd"");

     System.out.println(""a is""+a.toString());

     System.out.println(""b is""+b.toString());

      }

      } 运行结果是 C

     A 编译时会显现例外。

      B 运行结果为:

      a is First

      b is second

     C 运行结果为:

      a is First

      b is Secong a.k.a 2nd

     D 运行结果为:

      a is First a.k.a 1nd

      b is Second a.k.a 2nd

     12. abstract class MineBase {

     abstract void amethod();

      static int i;

     }

      public class Mine extends MineBase

      {

     public static void main(String argv[]){

      int[] ar = new int[5];

      for(i = 0;i < ar.length;i++)

      System.out.println(ar[i]);

     }

      } 程序编译运行结果是 C

     A 打印 5 个 0。

      B 编译出错,数组 ar[]必须初始化。

      C 编译出错, Mine 应声明为 abstract。

      D 显现 IndexOutOfBoundes 的例外。

      13. public class Foo{

      public static void main(String[] args){

     try{

      return;}

     finally{System.out.println(""Finally"");

     }

      }

     }

     结果是: B

     A 程序正常运行,但不输出任何结果。

      B 程序正常运行,并输出 ""Finally""。

      C 编译能通过,但运行时会显现一个例外。

      D 因为没有 catch 语句块,因此不能通过编译。

      14. 哪个表达式结果为 true? D Integer i = new Integer(42); Long h = new Long(42); Double d = new Double(42.0); Double dd = new Double(42);

      A

     i == h;

     B

     d == dd;

     C

     i.equals(h);

      D

     d.equals(dd);

      15. package 语句正确的选项是 A

      A 必须在程序开头

      B 不一定在程序开头

      C 能够在 import 之后

      D 包名能够以数字开头

      16. 有关类 Demo,哪句描述是正确的? A

     public class Demo extends Base{

     private int count;

     public Demo(){

      System.out.println(""A Demo object has been created"");

     }

     protected void addOne() {count++; }

     }

     A 当创建一个 Demo 类的实例对象时,count 的值为 0。

      B 当创建一个 Demo 类的实例对象时,count 的值是不确定的。

      C 超类对象中能够包含改变 count 值的方法。

      D Demo 的子类对象能够访问 count。

      17. java 中,关于 char 类型错误的选项是 C A 占 2 字节 B 能够储备一个英文字母 C 不能储备一个汉字 D 其对应的封装类是 Character

     18. 关于接口跟抽象类正确的选项是 C A 接口能够创建对象 B 抽象类能够创建对象 C 接口中不能定义变量,差不多上常量 D 接口中能够有 private 方法

     19. 关于内部类错误的选项是:A A 静态内部类能够访问其外部类的非静态属性 B 非静态内部类能够访问其外部类的静态属性 C 内部类能够是 protected D 内部类能够是 final 的

     20. 专门处理正确的选项是: B A 调用任何可能抛出专门方法,都必须捕捉 try catch 或者 throws B RuntimeException 能够不捕捉或者 throws C throw 跟 throws 用法是一样的 D try 必须有 catch,能够没有 finally

     21. Vector 与 ArrayList 正确的选项是: C A

     ArrayList 显现比 Vector 早

     B

     ArrayList 速度比 Vector 慢

     C

     ArrayList 没有同步爱护,Vector 具有同步爱护

     D

     ArrayList Vector 两者差不多上无序的集合"

     22. 下面在 Java 线程同步中差不多不举荐使用,应该幸免使用的方法是:

     D

     A join

      B notify

      C wait

      D suspend

     23. Which of the following lines of code will compile without error?

      B A.

     int i=0;

     if (i) {

     System.out.println(〝Hi〞);

     }

     B.

     boolean b=true;

     boolean b2=true;

     if(b=b2) {

     System.out.println(〝So true〞);

     }

     C.

     int i=1;

     int j=2;

     if(i==1! j==2)

     System.out.println(〝OK〞);

     D.

     int i=1;

     int j=2;

     if (i==1 &| j==2)

     System.out.println(〝OK〞);

      "

     24. 以下哪些组件能够为其设置布局治理器

     D

     A JDialog

     B JFrame

     C JWindow

     D JPanel

     25. 以下程序

     C class A

     {

     public static void main(String[] args)

      {

      B b = new B();

      b.run();

      for (int i=0;i<30;i++)

      {

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

      }

     } }

     class B extends Thread {

     public void run()

     {

      for (int i=0;i<30;i++)

      {

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

      }

      } };

     A 编译错误 B 编译正确,执行时 good hello 交替输出 C 编译正确,执行时先输出 30 个 hello 再输出 30 个 good D 编译正确,程序运行时显现专门

     26. 关于线程错误的选项是 D A 多线程共享同一数据可能显现错误,因此读写数据都需要加同步爱护 B 线程在 suspend 时,可不能开释同步锁,因此可能造成死锁,不举荐使用 C 线程在 wait 时,能够开释同步锁,因此线程通信时举荐使用。

     D 线程在 sleep 时,能够开释同步锁。

     27. FileInputStream 和 FileOutputStream 错误的选项是 C A 是字节流 B 是节点流 C 用其拷贝文件时,不能拷贝中文 D 能够拷贝任何文本文件和 2 进制文件。

     28. 以下错误的选项是 C A String 类对象具有不可改变的特性,对象内容无法改变 B StringBuffer 类内容能够改变 C 用 String 类比 StringBuffer 来做字符串运算比较节约内存 D String 类对象每次连接都创建一个新的对象

     29. 一个类中那些内容能够在序列化时写入文件或发送到网络上 D A transient 修饰的属性 B 静态属性 C 方法 D 类名

     30. 关于 Collection 接口错误的选项是:

     D A Collection 下面分为两个接口 Set 跟 List 接口 B Set 接口的实现类是无序无重复集合例如 HashSet C List 接口的实现类是有序能够重复集合例如 ArrayList 与 Vector D Map 接口也是 Collection 的子接口,实现类有 HashMap 和 Hashtable

     31. What happens when you try to compile and run the following application? Choose all correct options.

      A 1. public class Z {

     2. public static void main(String[] args) {

     3. new Z();

     4. }

     5.

     6. Z() {

     7. Z alias1 = this;

     8. Z alias2 = this;

     9. synchronized(alias1) {

     10. try {

     11. alias2.wait();

     12. System.out.println(〝DONE WAITING〞);

     13. }

     14. catch (InterruptedException e) {

     15. System.out.println(〝INTERRUPTED〞);

     16. }

     17. catch (Exception e) {

     18. System.out.println(〝OTHER EXCEPTION〞);

     19. }

     20. finally {

     21. System.out.println

     (〝FINALLY〞);

     22. }

     23. }

     24. System.out.println(〝ALL DONE〞);

     25. }

     26. }

     A. The application compiles but doesn’t print anything.

     B. The application compiles and print 〝DONE WAITING〞

     C. The application compiles and print 〝FINALLY〞

     D. The application compiles and print 〝ALL DONE〞

     E. The application compiles and print 〝INTERRUPTED〞

      32. 一个 Java applet 的 init()方法如下所示,关于该 applet 运行时显示的图形用户界面下述的论述是正确的 D

     public void init() {

      setLayout(new BorderLayout());

      add(""East"", new Button(""hello""));

     }

     选项:

     a) 在 applet 中什么也未显示

     b) 在 applet 窗口正中央显示一个按钮

     c) 在 applet 窗口的左侧显示一个按钮

     d) 在 applet 窗口的右侧显示一个按钮

     e) 一个按钮填充整个 applet 区域

     33. 以下关于关系数据库的说法正确的选项是:

     A 贮存在列下的数据不必具有相同数据类型。

     B 行是唯独的〔没有完全相同的行〕。

     C 列有顺序。

     D 行有顺序。

     34. 以下不属于 DML 数据操纵语句的是:D A insert B update C delete D commit

     35. 以下 sql 语句正确的选项是:D A select

     studentid,depart,count(*) from student group by depart; B select

     studentid,count(*) from student; C select

     depart,max(avg(age)) from student group by depart; D select studentid,avg(score),max(score) from score group by studentid

     36. 在 oracle 中提交之前,下面说法错误的选项是:D A 当前的用户能够看到 DML 操作的结果 B 其他用户不能看到 DML 操作的结果 C 被操作的数据被锁住,其他用户不能修改这些数据 D 所有的 savepoints 被去掉

     37. 在 JSP 中使用<jsp:getProperty>标记时,可不能显现的属...

    推荐访问:面试题 Java