4)?99.9:9));输出是______;4.Boolean类型booleana" />

Java程序员面试题

Java程序员面试题
Java程序员面试题

Java程序员面试题

1. 下列程序段执行后,t5的结果是_____.

int t1=5,t2=6,t3=7,t4,t5;

t4 = t1

t5 = t4

2.String s = new String("xyz");创建了_____个String Object.

3. 类型转换

int x=4;

System.out.println(“value is ” +((x>4)?99.9:9));输出是______;

4.Boolean类型

boolean a = false;

if (a = true){

System.out.println(true);

} else {

System.out.println(false); 结果是______;

5. int i = 5;

Integer iInteger = new Integer(i);

Integer jInteger = new Integer(i);

System.out.println(i == iInteger);

System.out.println(iInteger == jInteger);输出结果是______;

6.

TreeSet map = new TreeSet();

map.add("one");

map.add("two");

map.add("three");

map.add("four");

map.add("one");

Iterator it = map.iterator();

while (it.hasNext() ) {

System.out.print( it.next() + " " );

}

输出结果是________________________________________;

7

class Polish {

public static void main(String[] args) {

int x = 4;

StringBuffer sb = new StringBuffer("..fedcba");

sb.delete(3,6);

sb.insert(3, "az");

if(sb.length() > 6) x = sb.indexOf("b");

sb.delete((x-3), (x-2));

System.out.println(sb);

}

}

结果是:____________

8.class Emu {

static String s = "-";

public static void main(String[] args) {

try {

throw new Exception();

} catch (Exception e) {

try {

try { throw new Exception();

} catch (Exception ex) { s += "ic "; }

throw new Exception();

} catch (Exception x) { s += "mc "; }

finally { s += "mf "; }

} finally { s += "of "; }

System.out.println(s);结果是:______________________

9..抽象类和接口的区别

10.写一个方法,实现字符串的反转,如:输入abc,输出cba

11.short s1 =1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错?

12.下列哪些集合能够改变其容量大小,同时能够根据索引访问其元素,并且访问方法是非线形安全的?

A. java.util.HashSet

B. java.util.LinkedHashSet

C. java.util.List

D. java.util.ArrayList

E. java.util.Vector

F. java.util.PriorityQueue

13.下列关于泛型的说法,错误的是( )

A、泛型是一种参数化类型

B、可以取代继承机制。

C、避免了运行时进行类型转换可能的潜在性错误

D、增强了程序的灵活性和安全性

14. 下面关于System.out的说法哪些是正确?

A. System.out是1个PrintStream。

B. System.out是1个OutputStream。

C. System.out是1个FilterOutputStream。

D. System.out不是1个PrintStream。

E. System.out在异常时,将抛出IOException

15.String与StringBuffer的区别?

相关主题
相关文档
最新文档