<strike id="6q0um"></strike>
  • <strike id="6q0um"><s id="6q0um"></s></strike>
  • <ul id="6q0um"></ul><strike id="6q0um"></strike>

    當(dāng)前位置:高考升學(xué)網(wǎng) > 招聘筆試題 > 正文

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

    更新:2023-09-15 21:08:46 高考升學(xué)網(wǎng)

      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 分析:返回類型和參數(shù)列表必須完全一致,且訪問(wèn)修飾符必須大于被重寫方法的訪問(wèn)修飾符.

      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,但是我想不出來(lái)一個(gè)測(cè)試程序來(lái)驗(yàn)證C答案.希望高手們給我一個(gè)測(cè)試的例子吧,萬(wàn)分感謝..........

      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 分析:我感覺會(huì)出現(xiàn)不相等的情況,但是我說(shuō)不出為什么會(huì)相等。線程方面,還有好多路要走啊,咳

      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,網(wǎng)上有很多答案給錯(cuò)啦,大家注意啊。

      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");是一個(gè)動(dòng)作。

      而throws則是異常塊兒的聲明。所以感覺題目應(yīng)該是“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

    相關(guān)文章

    最新圖文

    2020年河北新聞網(wǎng)兩學(xué)一做

    時(shí)間:2023-09-18 07:0:24

    2020年河北新聞網(wǎng)兩學(xué)一做

    時(shí)間:2023-09-15 11:0:59

    兩學(xué)一做學(xué)習(xí)教育知

    時(shí)間:2023-09-21 06:0:30

    2020年開展兩學(xué)一做學(xué)習(xí)教

    時(shí)間:2023-09-19 21:0:30
    亚洲免费人成视频观看| 青青草原亚洲视频| 亚洲av片在线观看| 亚洲成A∨人片在线观看无码| 国产亚洲综合网曝门系列| 亚洲综合激情另类专区| 亚洲国产精品激情在线观看| 精品久久久久久久久亚洲偷窥女厕| 亚洲精品一二三区| 久久精品国产亚洲av麻豆蜜芽| 亚洲人成伊人成综合网久久| 亚洲免费福利视频| 67194在线午夜亚洲| 亚洲男人天堂2018av| 亚洲最大的成人网| 亚洲精品国产国语| 亚洲日韩中文字幕无码一区| 亚洲熟妇AV乱码在线观看| 亚洲码和欧洲码一码二码三码| 亚洲成a人片在线不卡一二三区 | 亚洲中文字幕日本无线码| 久久国产亚洲精品| 亚洲欧美日韩自偷自拍| 亚洲av无码专区在线观看下载| 色偷偷亚洲男人天堂| 亚洲国产综合无码一区二区二三区| 国产91精品一区二区麻豆亚洲| 黑人大战亚洲人精品一区| 亚洲精品少妇30p| 亚洲爆乳无码专区| 亚洲视频在线观看不卡| 亚洲av无码一区二区三区观看| 亚洲综合激情五月丁香六月| 色噜噜的亚洲男人的天堂| 亚洲国产综合精品一区在线播放| 色久悠悠婷婷综合在线亚洲| 亚洲AV永久无码精品一百度影院| 老汉色老汉首页a亚洲| 亚洲三级视频在线观看| 亚洲国产精品嫩草影院| 亚洲高清无码在线观看|