面试官考英文水平,好坑

面试官考英文水平,好坑


What will happen when you attempt to compile and run the following program by passing the Test class to the Java interpreter

Class Test {

public static void main(){

System.out.println(hello)

}

}

Select the one right answer.

a) The program does not compile because main() is not defined corrently.

b) The program compiles but when you try to run the interpreter complains that it cannot find the main() method it needs to run.

c) The program compiles but you cannot run it because the class is not declared as public

d) The program compiles and runs without an error but does not display anything in the standard output.

e) The program compiles and dispalys hello in the standard output when you run it.


5. Given these code snippets:

Boolean b1 = new Boolean(true);

Boolean b2 = new Boolean(true);

Which expressions are legal Java expression that return true?

Select all valid answers.

A) b1=b2

B) b1.equals(b2)

C) b1 & b2

D) b1 && b2

E) b1 && b2

F) b1 || b2

Given this code snippet:

Try {

tryThis();

Return;

}catch(IOException x1){

System.out.println(exception 1);

return;

}catch(Exception x2){

System.out.println(exception 2);

return;

}finally{

System.out.println(finally);

}

What will appear in the standard output if tryThis() throws a NumberFormatException?

Select the one right answer

A) Noting

B) exception2,followed by finally

C) exception 2,followed by finally

D) exception1

E) exception 2


Given these class definitions:

class Superclass{}

class Sbuclass1 extends Superclass {}

class Subclass2 extends Superclass {}

and these objects:

Superclass a = new Superclass();

Subclass1 b = new Subclass1();

Subclass2 c = new Subclass2();

Which of the following explains the result of the statement:

b=(Subclass)c;

Select the one right answer

A) Illegal at compile time

B) Legal at compile time but possibly illegal at runtime

C) Definitely legal at runtime


你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
不写代码的码农
李文凯

1 篇文章

作家榜 »

  1. majia 8 文章
  2. 刘娜娜 6 文章
  3. 在下选择隐性埋名 4 文章
  4. 上神白浅 3 文章
  5. 李家兴 2 文章
  6. 小马甲 2 文章
  7. 刘东鑫 1 文章
  8. 崔楷文 1 文章