欧美在线观看www-欧美在线观看高清一二三区-欧美在线观看网站-欧美在线观看网址-国产高清在线精品免费-国产高清在线精品一区二区

當前位置:高考升學網 > 招聘筆試題 > 正文

Java經典筆試題和面試題答案(三)

更新:2023-09-15 21:08:46 高考升學網

  26. class BaseClass{

  private float x=1.0f;

  private float getVar(){return x;}

  }

  class SubClass extends BaseClass{

  private float x=2.0f;

  //insert code

  }

  what are true to override getVar()?

  A.float getVar(){

  B.public float getVar(){

  C.public double getVar(){

  D.protected float getVar(){

  E.public float getVar(float f){

  Answer:A,B,D 分析:返回類型和參數列表必須完全一致,且訪問修飾符必須大于被重寫方法的訪問修飾符.

  27. public class SychTest{

  private int x;

  private int y;

  public void setX(int i){ x=i;}

  public void setY(int i){y=i;}

  public Synchronized void setXY(int i){

  setX(i);

  setY(i);

  }

  public Synchronized boolean check(){

  return x!=y;

  }

  }

  Under which conditions will check() return true when called from a different class?

  A.check() can never return true.

  B.check() can return true when setXY is callled by multiple threads.

  C.check() can return true when multiple threads call setX and setY separately.

  D.check() can only return true if SychTest is changed allow x and y to be set separately.

  Answer:C

  分析:答案是C,但是我想不出來一個測試程序來驗證C答案.希望高手們給我一個測試的例子吧,萬分感謝..........

  28. 1) public class X implements Runnable{

  2) private int x;

  3) private int y;

  4) public static void main(String[] args){

  5) X that =new X();

  6) (new Thread(that)).start();

  7) (new Thread(that)).start();

  }

  9) public synchronized void run(){

  10) for(;;){

  11) x++;

  12) y++;

  13) System.out.println("x="+x+",y="+y);

  14) }

  15) }

  16) }

  what is the result?

  A.compile error at line 6

  B.the program prints pairs of values for x and y that are always the same on the same time

  Answer:B 分析:我感覺會出現不相等的情況,但是我說不出為什么會相等。線程方面,還有好多路要走啊,咳

  29. class A implements Runnable{

  int i;

  public void run(){

  try{

  Thread.sleep(5000);

  i=10;

  }catch(InterruptedException e){}

  }

  public static void main(String[] args){

  try{

  A a=new A();

  Thread t=new Thread(a);

  t.start();

  17)

  int j=a.i;

  19)

  }catch(Exception e){}

  }

  }

  what be added at line line 17, ensure j=10 at line 19?

  A. a.wait(); B. t.wait(); C. t.join(); D.t.yield(); E.t.notify(); F. a.notify(); G.t.interrupt();

  Answer:C

  30. Given an ActionEvent, how to indentify the affected component?

  A.getTarget();

  B.getClass();

  C.getSource(); //public object

  D.getActionCommand();

  Answer:C

  31. import java.awt.;

  public class X extends Frame{

  public static void main(String[] args){

  X x=new X();

  x.pack();

  x.setVisible(true);

  }

  public X(){

  setLayout(new GridLayout(2,2));

  Panel p1=new Panel();

  add(p1);

  Button b1=new Button("One");

  p1.add(b1);

  Panel p2=new Panel();

  add(p2);

  Button b2=new Button("Two");

  p2.add(b2);

  Button b3=new Button("Three");

  p2.add(b3);

  Button b4=new Button("Four");

  add(b4);

  }

  }

  when the frame is resized,

  A.all change height B.all change width C.Button "One" change height

  D.Button "Two" change height E.Button "Three" change width

  F.Button "Four" change height and width

  Answer:F

  32. 1)public class X{

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

  3) String foo="ABCDE";

  4) foo.substring(3);

  5) foo.concat("XYZ");

  6) }

  7) }

  what is the value of foo at line 6?

  Answer:ABCDE

  33. How to calculate cosine 42 degree?

  A.double d=Math.cos(42);

  B.double d=Math.cosine(42);

  C.double d=Math.cos(Math.toRadians(42));

  D.double d=Math.cos(Math.toDegrees(42));

  E.double d=Math.toRadious(42);

  Answer:C

  34. public class Test{

  public static void main(String[] args){

  StringBuffer a=new StringBuffer("A");

  StringBuffer b=new StringBuffer("B");

  operate(a,b);

  System.out.pintln(a+","+b);

  }

  public static void operate(StringBuffer x, StringBuffer y){

  x.append(y);

  y=x;

  }

  }

  what is the output?

  Answer:AB,B 分析:這道題的答案是AB,B,網上有很多答案給錯啦,大家注意啊。

  35. 1) public class Test{

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

  3) class Foo{

  4) public int i=3;

  5) }

  6) Object o=(Object)new Foo();

  7) Foo foo=(Foo)o;

  System.out.println(foo.i);

  9) }

  10) }

  what is result?

  A.compile error at line 6

  B.compile error at line 7

  C.print out 3

  Answer:C

  36. public class FooBar{

  public static void main(String[] args){

  int i=0,j=5;

  4) tp: for(;;i++){

  for(;;--j)

  if(i>j)break tp;

  }

  System.out.println("i="+i+",j="+j);

  }

  }

  what is the result?

  A.i=1,j=-1 B. i=0,j=-1 C.i=1,j=4 D.i=0,j=4

  E.compile error at line 4

  Answer:B

  37. public class Foo{

  public static void main(String[] args){

  try{System.exit(0);}

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

  }

  }

  what is the result?

  A.print out nothing

  B.print out "Finally"

  Answer:A

  system.exit(0) has exit

  38. which four types of objects can be thrown use "throws"?

  A.Error

  B.Event

  C.Object

  D.Excption

  E.Throwable

  F.RuntimeException

  Answer:A,D,E,F

  分析:throw,例如:throw new IllegalAccessException("demo");是一個動作。

  而throws則是異常塊兒的聲明。所以感覺題目應該是“throw”

  39. 1)public class Test{

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

  3) unsigned byte b=0;

  4) b--;

  5)

  6) }

  7) }

  what is the value of b at line 5?

  A.-1 B.255 C.127 D.compile fail E.compile succeeded but run error

  Answer:D

  40. public class ExceptionTest{

  class TestException extends Exception{}

  public void runTest() throws TestException{}

  public void test() / point x / {

  runTest();

  }

  }

  At point x, which code can be add on to make the code compile?

  A.throws Exception B.catch (Exception e)

  Answer:A

  41. String foo="blue";

  boolean[] bar=new boolean;

  if(bar[0]){

  foo="green";

  }

  what is the value of foo?

  A."" B.null C.blue D.green

  Answer:C

  42. public class X{

  public static void main(String args[]){

  Object o1=new Object();

  Object o2=o1;

  if(o1.equals(o2)){

  System.out.prinln("Equal");

  }

  }

  }

  what is result?

  Answer:Equal

最新圖文

2020年河北新聞網兩學一做

時間:2023-09-18 07:0:24

2020年河北新聞網兩學一做

時間:2023-09-15 11:0:59

兩學一做學習教育知

時間:2023-09-21 06:0:30

2020年開展兩學一做學習教

時間:2023-09-19 21:0:30
主站蜘蛛池模板: 亚洲一区欧美日韩 | 日产精品卡2卡三卡乱码网站 | 久久久久免费精品视频 | 99国产精品国产精品 | 受胎岛无删减全集在线观看 | 男女免费高清在线爱做视频 | 春日迟迟再出发综艺在线观看免费 | 久久精品综合国产二区 | 日本精品国产 | aa级国产女人毛片好多水 | 欧美日韩亚洲视频 | 欧美一区二区日韩一区二区 | 亚洲精品98久久久久久中文字幕 | 久久99精品国产麻豆宅宅 | 99热免费在线观看 | 免费三级在线观看 | 一区二区精品在线观看 | 成人性一级视频在线观看 | 欧美网站在线 | 色在线免费 | 亚洲一区日韩二区欧美三区 | 综合色久七七综合七七蜜芽 | 国产精品久久久久一区二区三区 | 激情五月婷婷色 | 日本在线网 | 日本久久道一区二区三区 | 久久夜夜视频 | 国产在线91精品入口 | 美女操操 | 小婷的嫩苞在线播放 | 国产亚洲欧美一区二区 | 免费看黄视频的网站 | 国内精品自产拍在线观看91 | 精品久久亚洲 | 亚洲精品成人 | 国产在线精品一区二区夜色 | 99国产精品久久久久久久成人热 | 成人看片黄a在线看 | 欧洲亚洲视频 | www精品一区二区三区四区 | 岛国片免费|