EasyDemo*Java面试常见题
2017-09-08 23:36
357 查看
计算机基础
1.简述数据库的第三方范式 2.队列和堆栈各自的特性是什么?
3.什么是同步请求和异步请求,以及应用场景
4.请说出几种你熟悉或了解的设计模式的含义,应用场景(单例、工厂除外)二、单选题1.当你试图编译运行下列代码的时候会发生什么?public class WaNot{ int i = 0;public static void main(String[] args){WaNot w = new WaNot();w.amethod();}public void amethod(){while(true){try{wait();}catch(InterruptedException e){}i++;}//End of while }//End of amethod}//End of classA.Compile time error,no matching notify within the methodB.Compile and run but an infinite looping of the while methodC.Compilation and runD.Runtime Exception "IllegaMonitorStaException"
2.当你试着编译运行下面的两个放在同一个目录的问及那得时候,可能会发生什么?//File P2.javaclass P1{void afancymethod(){System.out.println("What a fancy method");}}//File P2.javapublic class P2 extends P1{afancymethod();}A.Both compile and P2 outputs"What a fancy method" when runB.Neither will compileC.Both compile but P2 has an error at run timeD.P1 compiles cleanly but P2 has an error at compile time
3.给定下面的类定义class Base{Base(int i){}} class DefCon extends Base{DefCon(int i){//XX}}如果将标记//XX的地方替换为下面的行,哪一行是独立合法的?A.super(); B.this();C.this(99); D.super(99);
4.下面那个语句是不能用于switch语句的参数?A.byte b = 1; B.int i = 1;C.boolean b = false; D.char c = 'c';
5.假如你写了一个程序用于读取8MB的文本文件,一行一行的读到一个String对象中, 但是你发现执行性能不好。最可能的解释是?A.java I/O是围绕最慢的设备而设计的,它本身很慢B.String类不适合I/O操作,字符数组将更合适<
20000
/span>C.因为String的不变性,每一次都要创建一个新的String对象,改为StringBuffer可能会提高性能D.以上都不正确
6.你希望存储少量数据并能快速访问。你并不需要排序这些数据,那种数据结构最适合这种需求?A.TreeSet B.HashMapC.LinkedList D.an array
7.下面哪段代码可以建议虚拟机执行垃圾收集?A.System.free(); B.System.setGarbageCollection();C.System.out.gc(); D.System.gc();
8.当你试图编译并运行如下代码时会发生什么?class Base{int i = 99;public void amethod(){System.out.println("Base.amethod()");}Base(){amethod();}}
public class RType extends Base{int i = -1;public static void main(String[] args){Base b = new RType();System.out.println(b.i);b.amethod();}public void amethod(){System.out.println("RType.amethod");}}A.RType.amethod B.RType.amethodC. D.-1 9999 RType.amethod RType.amethod RType.amethod Compile time error
9.如何从命令行中获取传递给主方法的值?A.Use the System.getParms()methodB.Assign an element of the argument to a stringC.Assign an element of the argument to a char arrayD.None of these options
10.假设有如下构造函数,mycon的元素1包含什么?MyCon(){int[] mycon = new int[5];}A.0 B.null C.3 D.None of these options
11.假设有如下类Class Base{int Age = 33;} 关于对Age域的访问,你会如何修改来改进这个类?A.Define the variable Age as privateB.Define the variable Age as protectedC.Define the variable Age as private and create a get method that returns it and a set method that updates itD.Define the variable Age as protected and create a get method that returns it and a set method that updates it
12.编译运行以下代码的结果是什么? Object o1 = new Object(); Object o2 = new Object(); o1 = o2; if(o1.equals(o2)){System.out.println("Equals"); }A.Compile time error B."Equals"C.No output D.Run time error
二、多选题: 1.下面哪种方式是推荐的让线程阻塞的方式?() A.sleep() B.wait/notifyC.suspend D.pause 2.下面哪些可以编译成功?() A.boolean b = -1; B.Boolean b2 = -false; C.int i = 019; D.char c = 99; 3.下面所述哪些是正确的() A.一个对象的hashCode方法会返回任何原始的证书类型 B.依据equals方法,两个相等的对象调用hashCode方法会生成同样的结果 C.一个对象的hashCode方法在一个应用程序的不同执行,一定会返回同样的值 D.Object类的hashCode方法签名是public int hashCode() 4.以下哪个要求程序员添加外部的try/catch异常处理?() A.Traversing each member of an array B.Attempting to open a file C.Attempting to open a network socket D.Accessing a method in other class 三、简答题: 1.简述一下对JVM、JRE、J2EE规范的认识 四、编程题:(优先编写代码,可选择伪代码或阐述思路0) 1.用JAVA SOCKET编程,读取服务器上的几个字符,再写入本地显示?
2.用java编程,编写一个截取字符的函数,输入为一个字符串和字节数,输出为 按字节截取的字符串,但是要保证汉字不被截取,如"我ABC",应该截为"我AB", 输出为"我ABC汉DEF",因该输出为"我ABC"而不是"我ABC+汉的半个".
计算机基础
1.简述数据库的第三方范式 2.队列和堆栈各自的特性是什么?
3.什么是同步请求和异步请求,以及应用场景
4.请说出几种你熟悉或了解的设计模式的含义,应用场景(单例、工厂除外)二、单选题1.当你试图编译运行下列代码的时候会发生什么?public class WaNot{ int i = 0;public static void main(String[] args){WaNot w = new WaNot();w.amethod();}public void amethod(){while(true){try{wait();}catch(InterruptedException e){}i++;}//End of while }//End of amethod}//End of classA.Compile time error,no matching notify within the methodB.Compile and run but an infinite looping of the while methodC.Compilation and runD.Runtime Exception "IllegaMonitorStaException"
2.当你试着编译运行下面的两个放在同一个目录的问及那得时候,可能会发生什么?//File P2.javaclass P1{void afancymethod(){System.out.println("What a fancy method");}}//File P2.javapublic class P2 extends P1{afancymethod();}A.Both compile and P2 outputs"What a fancy method" when runB.Neither will compileC.Both compile but P2 has an error at run timeD.P1 compiles cleanly but P2 has an error at compile time
3.给定下面的类定义class Base{Base(int i){}} class DefCon extends Base{DefCon(int i){//XX}}如果将标记//XX的地方替换为下面的行,哪一行是独立合法的?A.super(); B.this();C.this(99); D.super(99);
4.下面那个语句是不能用于switch语句的参数?A.byte b = 1; B.int i = 1;C.boolean b = false; D.char c = 'c';
5.假如你写了一个程序用于读取8MB的文本文件,一行一行的读到一个String对象中, 但是你发现执行性能不好。最可能的解释是?A.java I/O是围绕最慢的设备而设计的,它本身很慢B.String类不适合I/O操作,字符数组将更合适C.因为String的不变性,每一次都要创建一个新的String对象,改为StringBuffer可能会提高性能D.以上都不正确
6.你希望存储少量数据并能快速访问。你并不需要排序这些数据,那种数据结构最适合这种需求?A.TreeSet B.HashMapC.LinkedList D.an array
7.下面哪段代码可以建议虚拟机执行垃圾收集?A.System.free(); B.System.setGarbageCollection();C.System.out.gc(); D.System.gc();
8.当你试图编译并运行如下代码时会发生什么?class Base{int i = 99;public void amethod(){System.out.println("Base.amethod()");}Base(){amethod();}}
public class RType extends Base{int i = -1;public static void main(String[] args){Base b = new RType();System.out.println(b.i);b.amethod();}public void amethod(){System.out.println("RType.amethod");}}A.RType.amethod B.RType.amethodC. D.-1 9999 RType.amethod RType.amethod RType.amethod Compile time error
9.如何从命令行中获取传递给主方法的值?A.Use the System.getParms()methodB.Assign an element of the argument to a stringC.Assign an element of the argument to a char arrayD.None of these options
10.假设有如下构造函数,mycon的元素1包含什么?MyCon(){int[] mycon = new int[5];}A.0 B.null C.3 D.None of these options
11.假设有如下类Class Base{int Age = 33;} 关于对Age域的访问,你会如何修改来改进这个类?A.Define the variable Age as privateB.Define the variable Age as protectedC.Define the variable Age as private and create a get method that returns it and a set method that updates itD.Define the variable Age as protected and create a get method that returns it and a set method that updates it
12.编译运行以下代码的结果是什么? Object o1 = new Object(); Object o2 = new Object(); o1 = o2; if(o1.equals(o2)){System.out.println("Equals"); }A.Compile time error B."Equals"C.No output D.Run time error
二、多选题: 1.下面哪种方式是推荐的让线程阻塞的方式?() A.sleep() B.wait/notifyC.suspend D.pause 2.下面哪些可以编译成功?() A.boolean b = -1; B.Boolean b2 = -false; C.int i = 019; D.char c = 99; 3.下面所述哪些是正确的() A.一个对象的hashCode方法会返回任何原始的证书类型 B.依据equals方法,两个相等的对象调用hashCode方法会生成同样的结果 C.一个对象的hashCode方法在一个应用程序的不同执行,一定会返回同样的值 D.Object类的hashCode方法签名是public int hashCode() 4.以下哪个要求程序员添加外部的try/catch异常处理?() A.Traversing each member of an array B.Attempting to open a file C.Attempting to open a network socket D.Accessing a method in other class 三、简答题: 1.简述一下对JVM、JRE、J2EE规范的认识 四、编程题:(优先编写代码,可选择伪代码或阐述思路0) 1.用JAVA SOCKET编程,读取服务器上的几个字符,再写入本地显示?
2.用java编程,编写一个截取字符的函数,输入为一个字符串和字节数,输出为 按字节截取的字符串,但是要保证汉字不被截取,如"我ABC",应该截为"我AB", 输出为"我ABC汉DEF",因该输出为"我ABC"而不是"我ABC+汉的半个".计算机基础
1.简述数据库的第三方范式 2.队列和堆栈各自的特性是什么?
3.什么是同步请求和异步请求,以及应用场景
4.请说出几种你熟悉或了解的设计模式的含义,应用场景(单例、工厂除外)二、单选题1.当你试图编译运行下列代码的时候会发生什么?public class WaNot{ int i = 0;public static void main(String[] args){WaNot w = new WaNot();w.amethod();}public void amethod(){while(true){try{wait();}catch(InterruptedException e){}i++;}//End of while }//End of amethod}//End of classA.Compile time error,no matching notify within the methodB.Compile and run but an infinite looping of the while methodC.Compilation and runD.Runtime Exception "IllegaMonitorStaException"
2.当你试着编译运行下面的两个放在同一个目录的问及那得时候,可能会发生什么?//File P2.javaclass P1{void afancymethod(){System.out.println("What a fancy method");}}//File P2.javapublic class P2 extends P1{afancymethod();}A.Both compile and P2 outputs"What a fancy method" when runB.Neither will compileC.Both compile but P2 has an error at run timeD.P1 compiles cleanly but P2 has an error at compile time
3.给定下面的类定义class Base{Base(int i){}} class DefCon extends Base{DefCon(int i){//XX}}如果将标记//XX的地方替换为下面的行,哪一行是独立合法的?A.super(); B.this();C.this(99); D.super(99);
4.下面那个语句是不能用于switch语句的参数?A.byte b = 1; B.int i = 1;C.boolean b = false; D.char c = 'c';
5.假如你写了一个程序用于读取8MB的文本文件,一行一行的读到一个String对象中, 但是你发现执行性能不好。最可能的解释是?A.java I/O是围绕最慢的设备而设计的,它本身很慢B.String类不适合I/O操作,字符数组将更合适C.因为String的不变性,每一次都要创建一个新的String对象,改为StringBuffer可能会提高性能D.以上都不正确
6.你希望存储少量数据并能快速访问。你并不需要排序这些数据,那种数据结构最适合这种需求?A.TreeSet B.HashMapC.LinkedList D.an array
7.下面哪段代码可以建议虚拟机执行垃圾收集?A.System.free(); B.System.setGarbageCollection();C.System.out.gc(); D.System.gc();
8.当你试图编译并运行如下代码时会发生什么?class Base{int i = 99;public void amethod(){System.out.println("Base.amethod()");}Base(){amethod();}}
public class RType extends Base{int i = -1;public static void main(String[] args){Base b = new RType();System.out.println(b.i);b.amethod();}public void amethod(){System.out.println("RType.amethod");}}A.RType.amethod B.RType.amethodC. D.-1 9999 RType.amethod RType.amethod RType.amethod Compile time error
9.如何从命令行中获取传递给主方法的值?A.Use the System.getParms()methodB.Assign an element of the argument to a stringC.Assign an element of the argument to a char arrayD.None of these options
10.假设有如下构造函数,mycon的元素1包含什么?MyCon(){int[] mycon = new int[5];}A.0 B.null C.3 D.None of these options
11.假设有如下类Class Base{int Age = 33;} 关于对Age域的访问,你会如何修改来改进这个类?A.Define the variable Age as privateB.Define the variable Age as protectedC.Define the variable Age as private and create a get method that returns it and a set method that updates itD.Define the variable Age as protected and create a get method that returns it and a set method that updates it
12.编译运行以下代码的结果是什么? Object o1 = new Object(); Object o2 = new Object(); o1 = o2; if(o1.equals(o2)){System.out.println("Equals"); }A.Compile time error B."Equals"C.No output D.Run time error
二、多选题: 1.下面哪种方式是推荐的让线程阻塞的方式?() A.sleep() B.wait/notifyC.suspend D.pause 2.下面哪些可以编译成功?() A.boolean b = -1; B.Boolean b2 = -false; C.int i = 019; D.char c = 99; 3.下面所述哪些是正确的() A.一个对象的hashCode方法会返回任何原始的证书类型 B.依据equals方法,两个相等的对象调用hashCode方法会生成同样的结果 C.一个对象的hashCode方法在一个应用程序的不同执行,一定会返回同样的值 D.Object类的hashCode方法签名是public int hashCode() 4.以下哪个要求程序员添加外部的try/catch异常处理?() A.Traversing each member of an array B.Attempting to open a file C.Attempting to open a network socket D.Accessing a method in other class 三、简答题: 1.简述一下对JVM、JRE、J2EE规范的认识 四、编程题:(优先编写代码,可选择伪代码或阐述思路0) 1.用JAVA SOCKET编程,读取服务器上的几个字符,再写入本地显示?
2.用java编程,编写一个截取字符的函数,输入为一个字符串和字节数,输出为 按字节截取的字符串,但是要保证汉字不被截取,如"我ABC",应该截为"我AB", 输出为"我ABC汉DEF",因该输出为"我ABC"而不是"我ABC+汉的半个".
1.简述数据库的第三方范式 2.队列和堆栈各自的特性是什么?
3.什么是同步请求和异步请求,以及应用场景
4.请说出几种你熟悉或了解的设计模式的含义,应用场景(单例、工厂除外)二、单选题1.当你试图编译运行下列代码的时候会发生什么?public class WaNot{ int i = 0;public static void main(String[] args){WaNot w = new WaNot();w.amethod();}public void amethod(){while(true){try{wait();}catch(InterruptedException e){}i++;}//End of while }//End of amethod}//End of classA.Compile time error,no matching notify within the methodB.Compile and run but an infinite looping of the while methodC.Compilation and runD.Runtime Exception "IllegaMonitorStaException"
2.当你试着编译运行下面的两个放在同一个目录的问及那得时候,可能会发生什么?//File P2.javaclass P1{void afancymethod(){System.out.println("What a fancy method");}}//File P2.javapublic class P2 extends P1{afancymethod();}A.Both compile and P2 outputs"What a fancy method" when runB.Neither will compileC.Both compile but P2 has an error at run timeD.P1 compiles cleanly but P2 has an error at compile time
3.给定下面的类定义class Base{Base(int i){}} class DefCon extends Base{DefCon(int i){//XX}}如果将标记//XX的地方替换为下面的行,哪一行是独立合法的?A.super(); B.this();C.this(99); D.super(99);
4.下面那个语句是不能用于switch语句的参数?A.byte b = 1; B.int i = 1;C.boolean b = false; D.char c = 'c';
5.假如你写了一个程序用于读取8MB的文本文件,一行一行的读到一个String对象中, 但是你发现执行性能不好。最可能的解释是?A.java I/O是围绕最慢的设备而设计的,它本身很慢B.String类不适合I/O操作,字符数组将更合适<
20000
/span>C.因为String的不变性,每一次都要创建一个新的String对象,改为StringBuffer可能会提高性能D.以上都不正确
6.你希望存储少量数据并能快速访问。你并不需要排序这些数据,那种数据结构最适合这种需求?A.TreeSet B.HashMapC.LinkedList D.an array
7.下面哪段代码可以建议虚拟机执行垃圾收集?A.System.free(); B.System.setGarbageCollection();C.System.out.gc(); D.System.gc();
8.当你试图编译并运行如下代码时会发生什么?class Base{int i = 99;public void amethod(){System.out.println("Base.amethod()");}Base(){amethod();}}
public class RType extends Base{int i = -1;public static void main(String[] args){Base b = new RType();System.out.println(b.i);b.amethod();}public void amethod(){System.out.println("RType.amethod");}}A.RType.amethod B.RType.amethodC. D.-1 9999 RType.amethod RType.amethod RType.amethod Compile time error
9.如何从命令行中获取传递给主方法的值?A.Use the System.getParms()methodB.Assign an element of the argument to a stringC.Assign an element of the argument to a char arrayD.None of these options
10.假设有如下构造函数,mycon的元素1包含什么?MyCon(){int[] mycon = new int[5];}A.0 B.null C.3 D.None of these options
11.假设有如下类Class Base{int Age = 33;} 关于对Age域的访问,你会如何修改来改进这个类?A.Define the variable Age as privateB.Define the variable Age as protectedC.Define the variable Age as private and create a get method that returns it and a set method that updates itD.Define the variable Age as protected and create a get method that returns it and a set method that updates it
12.编译运行以下代码的结果是什么? Object o1 = new Object(); Object o2 = new Object(); o1 = o2; if(o1.equals(o2)){System.out.println("Equals"); }A.Compile time error B."Equals"C.No output D.Run time error
二、多选题: 1.下面哪种方式是推荐的让线程阻塞的方式?() A.sleep() B.wait/notifyC.suspend D.pause 2.下面哪些可以编译成功?() A.boolean b = -1; B.Boolean b2 = -false; C.int i = 019; D.char c = 99; 3.下面所述哪些是正确的() A.一个对象的hashCode方法会返回任何原始的证书类型 B.依据equals方法,两个相等的对象调用hashCode方法会生成同样的结果 C.一个对象的hashCode方法在一个应用程序的不同执行,一定会返回同样的值 D.Object类的hashCode方法签名是public int hashCode() 4.以下哪个要求程序员添加外部的try/catch异常处理?() A.Traversing each member of an array B.Attempting to open a file C.Attempting to open a network socket D.Accessing a method in other class 三、简答题: 1.简述一下对JVM、JRE、J2EE规范的认识 四、编程题:(优先编写代码,可选择伪代码或阐述思路0) 1.用JAVA SOCKET编程,读取服务器上的几个字符,再写入本地显示?
2.用java编程,编写一个截取字符的函数,输入为一个字符串和字节数,输出为 按字节截取的字符串,但是要保证汉字不被截取,如"我ABC",应该截为"我AB", 输出为"我ABC汉DEF",因该输出为"我ABC"而不是"我ABC+汉的半个".
计算机基础
1.简述数据库的第三方范式 2.队列和堆栈各自的特性是什么?
3.什么是同步请求和异步请求,以及应用场景
4.请说出几种你熟悉或了解的设计模式的含义,应用场景(单例、工厂除外)二、单选题1.当你试图编译运行下列代码的时候会发生什么?public class WaNot{ int i = 0;public static void main(String[] args){WaNot w = new WaNot();w.amethod();}public void amethod(){while(true){try{wait();}catch(InterruptedException e){}i++;}//End of while }//End of amethod}//End of classA.Compile time error,no matching notify within the methodB.Compile and run but an infinite looping of the while methodC.Compilation and runD.Runtime Exception "IllegaMonitorStaException"
2.当你试着编译运行下面的两个放在同一个目录的问及那得时候,可能会发生什么?//File P2.javaclass P1{void afancymethod(){System.out.println("What a fancy method");}}//File P2.javapublic class P2 extends P1{afancymethod();}A.Both compile and P2 outputs"What a fancy method" when runB.Neither will compileC.Both compile but P2 has an error at run timeD.P1 compiles cleanly but P2 has an error at compile time
3.给定下面的类定义class Base{Base(int i){}} class DefCon extends Base{DefCon(int i){//XX}}如果将标记//XX的地方替换为下面的行,哪一行是独立合法的?A.super(); B.this();C.this(99); D.super(99);
4.下面那个语句是不能用于switch语句的参数?A.byte b = 1; B.int i = 1;C.boolean b = false; D.char c = 'c';
5.假如你写了一个程序用于读取8MB的文本文件,一行一行的读到一个String对象中, 但是你发现执行性能不好。最可能的解释是?A.java I/O是围绕最慢的设备而设计的,它本身很慢B.String类不适合I/O操作,字符数组将更合适C.因为String的不变性,每一次都要创建一个新的String对象,改为StringBuffer可能会提高性能D.以上都不正确
6.你希望存储少量数据并能快速访问。你并不需要排序这些数据,那种数据结构最适合这种需求?A.TreeSet B.HashMapC.LinkedList D.an array
7.下面哪段代码可以建议虚拟机执行垃圾收集?A.System.free(); B.System.setGarbageCollection();C.System.out.gc(); D.System.gc();
8.当你试图编译并运行如下代码时会发生什么?class Base{int i = 99;public void amethod(){System.out.println("Base.amethod()");}Base(){amethod();}}
public class RType extends Base{int i = -1;public static void main(String[] args){Base b = new RType();System.out.println(b.i);b.amethod();}public void amethod(){System.out.println("RType.amethod");}}A.RType.amethod B.RType.amethodC. D.-1 9999 RType.amethod RType.amethod RType.amethod Compile time error
9.如何从命令行中获取传递给主方法的值?A.Use the System.getParms()methodB.Assign an element of the argument to a stringC.Assign an element of the argument to a char arrayD.None of these options
10.假设有如下构造函数,mycon的元素1包含什么?MyCon(){int[] mycon = new int[5];}A.0 B.null C.3 D.None of these options
11.假设有如下类Class Base{int Age = 33;} 关于对Age域的访问,你会如何修改来改进这个类?A.Define the variable Age as privateB.Define the variable Age as protectedC.Define the variable Age as private and create a get method that returns it and a set method that updates itD.Define the variable Age as protected and create a get method that returns it and a set method that updates it
12.编译运行以下代码的结果是什么? Object o1 = new Object(); Object o2 = new Object(); o1 = o2; if(o1.equals(o2)){System.out.println("Equals"); }A.Compile time error B."Equals"C.No output D.Run time error
二、多选题: 1.下面哪种方式是推荐的让线程阻塞的方式?() A.sleep() B.wait/notifyC.suspend D.pause 2.下面哪些可以编译成功?() A.boolean b = -1; B.Boolean b2 = -false; C.int i = 019; D.char c = 99; 3.下面所述哪些是正确的() A.一个对象的hashCode方法会返回任何原始的证书类型 B.依据equals方法,两个相等的对象调用hashCode方法会生成同样的结果 C.一个对象的hashCode方法在一个应用程序的不同执行,一定会返回同样的值 D.Object类的hashCode方法签名是public int hashCode() 4.以下哪个要求程序员添加外部的try/catch异常处理?() A.Traversing each member of an array B.Attempting to open a file C.Attempting to open a network socket D.Accessing a method in other class 三、简答题: 1.简述一下对JVM、JRE、J2EE规范的认识 四、编程题:(优先编写代码,可选择伪代码或阐述思路0) 1.用JAVA SOCKET编程,读取服务器上的几个字符,再写入本地显示?
2.用java编程,编写一个截取字符的函数,输入为一个字符串和字节数,输出为 按字节截取的字符串,但是要保证汉字不被截取,如"我ABC",应该截为"我AB", 输出为"我ABC汉DEF",因该输出为"我ABC"而不是"我ABC+汉的半个".计算机基础
1.简述数据库的第三方范式 2.队列和堆栈各自的特性是什么?
3.什么是同步请求和异步请求,以及应用场景
4.请说出几种你熟悉或了解的设计模式的含义,应用场景(单例、工厂除外)二、单选题1.当你试图编译运行下列代码的时候会发生什么?public class WaNot{ int i = 0;public static void main(String[] args){WaNot w = new WaNot();w.amethod();}public void amethod(){while(true){try{wait();}catch(InterruptedException e){}i++;}//End of while }//End of amethod}//End of classA.Compile time error,no matching notify within the methodB.Compile and run but an infinite looping of the while methodC.Compilation and runD.Runtime Exception "IllegaMonitorStaException"
2.当你试着编译运行下面的两个放在同一个目录的问及那得时候,可能会发生什么?//File P2.javaclass P1{void afancymethod(){System.out.println("What a fancy method");}}//File P2.javapublic class P2 extends P1{afancymethod();}A.Both compile and P2 outputs"What a fancy method" when runB.Neither will compileC.Both compile but P2 has an error at run timeD.P1 compiles cleanly but P2 has an error at compile time
3.给定下面的类定义class Base{Base(int i){}} class DefCon extends Base{DefCon(int i){//XX}}如果将标记//XX的地方替换为下面的行,哪一行是独立合法的?A.super(); B.this();C.this(99); D.super(99);
4.下面那个语句是不能用于switch语句的参数?A.byte b = 1; B.int i = 1;C.boolean b = false; D.char c = 'c';
5.假如你写了一个程序用于读取8MB的文本文件,一行一行的读到一个String对象中, 但是你发现执行性能不好。最可能的解释是?A.java I/O是围绕最慢的设备而设计的,它本身很慢B.String类不适合I/O操作,字符数组将更合适C.因为String的不变性,每一次都要创建一个新的String对象,改为StringBuffer可能会提高性能D.以上都不正确
6.你希望存储少量数据并能快速访问。你并不需要排序这些数据,那种数据结构最适合这种需求?A.TreeSet B.HashMapC.LinkedList D.an array
7.下面哪段代码可以建议虚拟机执行垃圾收集?A.System.free(); B.System.setGarbageCollection();C.System.out.gc(); D.System.gc();
8.当你试图编译并运行如下代码时会发生什么?class Base{int i = 99;public void amethod(){System.out.println("Base.amethod()");}Base(){amethod();}}
public class RType extends Base{int i = -1;public static void main(String[] args){Base b = new RType();System.out.println(b.i);b.amethod();}public void amethod(){System.out.println("RType.amethod");}}A.RType.amethod B.RType.amethodC. D.-1 9999 RType.amethod RType.amethod RType.amethod Compile time error
9.如何从命令行中获取传递给主方法的值?A.Use the System.getParms()methodB.Assign an element of the argument to a stringC.Assign an element of the argument to a char arrayD.None of these options
10.假设有如下构造函数,mycon的元素1包含什么?MyCon(){int[] mycon = new int[5];}A.0 B.null C.3 D.None of these options
11.假设有如下类Class Base{int Age = 33;} 关于对Age域的访问,你会如何修改来改进这个类?A.Define the variable Age as privateB.Define the variable Age as protectedC.Define the variable Age as private and create a get method that returns it and a set method that updates itD.Define the variable Age as protected and create a get method that returns it and a set method that updates it
12.编译运行以下代码的结果是什么? Object o1 = new Object(); Object o2 = new Object(); o1 = o2; if(o1.equals(o2)){System.out.println("Equals"); }A.Compile time error B."Equals"C.No output D.Run time error
二、多选题: 1.下面哪种方式是推荐的让线程阻塞的方式?() A.sleep() B.wait/notifyC.suspend D.pause 2.下面哪些可以编译成功?() A.boolean b = -1; B.Boolean b2 = -false; C.int i = 019; D.char c = 99; 3.下面所述哪些是正确的() A.一个对象的hashCode方法会返回任何原始的证书类型 B.依据equals方法,两个相等的对象调用hashCode方法会生成同样的结果 C.一个对象的hashCode方法在一个应用程序的不同执行,一定会返回同样的值 D.Object类的hashCode方法签名是public int hashCode() 4.以下哪个要求程序员添加外部的try/catch异常处理?() A.Traversing each member of an array B.Attempting to open a file C.Attempting to open a network socket D.Accessing a method in other class 三、简答题: 1.简述一下对JVM、JRE、J2EE规范的认识 四、编程题:(优先编写代码,可选择伪代码或阐述思路0) 1.用JAVA SOCKET编程,读取服务器上的几个字符,再写入本地显示?
2.用java编程,编写一个截取字符的函数,输入为一个字符串和字节数,输出为 按字节截取的字符串,但是要保证汉字不被截取,如"我ABC",应该截为"我AB", 输出为"我ABC汉DEF",因该输出为"我ABC"而不是"我ABC+汉的半个".
相关文章推荐
- EasyDemo*Java面试常见题
- EasyDemo*Java面试常见题
- EasyDemo*Java面试常见题
- EasyDemo*java面试常见题
- EasyDemo*android面试常见题
- EasyDemo*android面试常见题
- EasyDemo*40个比较重要的Android面试常见题
- EasyDemo*andorid面试常见题
- 面试10大算法汇总+常见题目解答(Java)
- java面试常见问题
- Java按值传递和按址传递(面试常见)
- JAVA面试常见问题
- [面试][算法] 常见10种算法 java 实现
- java异常面试常见题目
- Java常见面试内容
- EasyDemo*JavaSE 基础知识点体系结构图(download pic Thx)
- Java/大数据常见面试
- [笔面] Java开发常见面试题目
- [Java面试]六:常见面试题之设计模式
- Android开发面试经——3.常见Java基础笔试题