欧美在线观看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
主站蜘蛛池模板: 亚洲日本天堂 | 秋霞看片亚洲先锋一区 | 99精品国产第一福利网站 | 俺也来国产精品欧美在线观看 | 岛国大片免费在线观看 | 午夜视频免费在线播放 | 在线a久青草视频在线观看g | 99热免费在线观看 | 天天夜日日日日碰日日摸 | 欧美激情一级欧美精品 | 国产小视频在线看 | 久草看片 | 在线播放第一页 | 午夜免费观看_视频在线观看 | 国产精品视频专区 | 欧美一区二区高清 | 看国产毛片 | 亚洲国产欧美国产第一区二区三区 | 国产一区二区三区日韩 | 日本肥婆| 九九色网 | 男人扒开你的下面狂躁的视频 | 高清国产精品久久久久 | 天天色踪合合 | 日韩亚洲| 老外毛片| 国产精品国产亚洲精品不卡 | 国产免费一区二区三区免费视频 | 蜜柚在线观看 | 欧美一区二区三区日韩免费播 | 美女在线网站视频免费观看 | 中文字幕在线播放一区 | 国产青草| 最新香蕉97超级碰碰碰碰碰久 | 国产三级成人 | aaa大片| 亚洲 欧洲 自拍 另类 校园 | 欧美成人精品三级网站 | 日本精品a在线观看 | 欧美日韩麻豆 | 欧美黑寡妇香蕉视频 |