<dfn id="w48us"></dfn><ul id="w48us"></ul>
  • <ul id="w48us"></ul>
  • <del id="w48us"></del>
    <ul id="w48us"></ul>
  • Sun java認證考試答案

    時間:2024-11-06 19:44:10 SUN認證 我要投稿

    Sun java認證考試答案

      SUN認證是給網(wǎng)絡設計界建立的一套認證標準,Sun公司推出了Java以及Solaris技術認證方案。小編收集一些Sun java認證考試真題答案,希望發(fā)夾認真做題!

    Sun java認證考試答案

      1. What gets printed when the following program

      is compiled and run?

      class Test {

      public static void main(String args[]) {

      int i;

      do {

      i++;

      } while (i < 0);

      System.out.println(i);

      }

      }

      Select 1 correct answer:

      A. The program does not compile as i is not initialized.

      B. The program compiles but does not run.

      C. The program compiles and runs but does not print anything.

      D. The program prints 0.

      E. The program prints 1.

      答案:A:如果沒有初始化便使用基本變量類型,會導致編譯時異常,程序不能編譯。

      2. What gets printed when the following program

      is compiled and run?

      public class XYZ {

      public static void main(String args[]) {

      int i,j,k;

      for (i = 0; i < 3; i++)

      {

      for(j=1; j < 4; j++)

      {

      for(k=2; k<5; k++)

      {

      if((i == j) && (j==k))

      System.out.println(i);

      } } } } }

      Select 1 correct answer:

      A. 0

      B. 1

      C. 2

      D. 3

      E. 4

      答案:C

      3. Given the following code :

      class Base{}

      public class MyCast extends Base{

      static boolean b1=false;

      static int i = -1;

      static double d = 10.1;

      public static void main(String argv[]){

      MyCast m = new MyCast();

      Base b = new Base();

      //Here

      }

      }

      Which of the following, if inserted at the comment //Here

      will allow the code to compile and run without error?

      Select 2 correct answers:

      A. b = m;

      B. m = b;

      C. d = i;

      D. b1 = i;

      解析:A 從子類型到父類型的轉換是擴展引用轉換,不需要在運行時采取特殊的動作,不會在運行時拋出異常。

      B 從超類型到子類型的轉換是收縮引用轉換,需要在運行時執(zhí)行測試,以查明實際的引用值是否是新類型的合法值.如果不是, 則會拋出ClassCascException 。在這里,b本身不是MyCast類型的值,因此會導致運行時異常。

      C 從int到double的轉換是擴展基本轉換,基本類型之間的擴展轉換永遠不會導致運行時異常。但從int或long到float,或者是從long到double都可能導致精度丟失。

      D 不允許進行int和boolean之間的類型轉換

      答案:A、C

      4. Given the following classes which of the following

      will compile without error?

      interface IFace{}

      class CFace implements IFace{}

      class Base{}

      public class ObRef extends Base{

      public static void main(String argv[])

      {

      ObRef ob = new ObRef();

      Base b = new Base();

      Object o1 = new Object();

      IFace o2 = new CFace();

      }

      }

      Select 3 correct answers:

      A. o1 = o2;

      B. b = ob;

      C. ob = b;

      D. o1 = b;

      解析:A 任何對象都可以賦給Object類型的對象,正確

      B 子類賦給超類是擴展引用轉換,可以進行

      C 收縮引用轉換,錯誤

      D 擴展引用轉換,可以進行

      答案 A B D

      5. What is the result of compiling and running the following code?

      1 public class Test {

      2 static int total = 10;

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

      4 new Test();

      5 }

      6 public Test () {

      7 System.out.println("In test");

      8 System.out.println(this);

      9 int temp = this.total;

      10 if (temp > 5) {

      11 System.out.println(temp);

      12 }

      13 }

      14 }

      Select 1 correct answer:

      A. The class will not compile

      B. The compiler reports an error at line 2

      C. The compiler reports an error at line 9

      D. The value 10 is one of the printed elements

      E. The class compiles but generates a runtime error

      答案:D 由于test類沒有override toString方法,故在調用println(this)時會直接顯示類的有關信息。

      6. Carefully examine the following code:

      public class StaticTest {

      static { System.out.println("Hi there"); }

      public void print() {

      System.out.println("Hello");

      }

      public static void main(String args []) {

      StaticTest st1 = new StaticTest();

      st1.print();

      StaticTest st2 = new StaticTest();

      st2.print();

      }}

      When will the string "Hi there" be printed?

      Select 1 correct answer:

      A. Never

      B. Each time a new instance is created

      C. Once, when the class is first loaded into the JVM

      D. Only when the static method is called explicitly

      答案 C

      Java虛擬機規(guī)范約定,類的初始化發(fā)生在首次主動使用時。靜態(tài)變量和靜態(tài)初始化塊的先后,實際上取決于它們在類中出現(xiàn)的先后順序。

      7. Given the following code what is the effect of a being 5?

      public class Test {

      public void add(int a) {

      loop: for (int i = 1; i < 3; i++){

      for (int j = 1; j < 3; j++) {

      if (a == 5) {

      break loop;

      }

      System.out.println(i * j);

      }

      }

      }

      }

      Select 1 correct answer:

      A. Generates a runtime error

      B. Throws an ArrayIndexOutOfBoundsException

      C. Prints the values: 1, 2, 2, 4

      D. Produces no output

      解析:考察標記和break的使用。單純使用break只跳出當前循環(huán)(一層)。如果在要跳出的循環(huán)前加標記,那么在加過標記的循環(huán)中的任何地方都可以使用break 標記 來跳出該循環(huán)

      答案:D

    【Sun java認證考試答案】相關文章:

    Sun java認證考試真題答案09-25

    sun java認證考試介紹10-23

    Sun Java認證考試科目08-30

    sun java認證考試報考指南10-18

    SUN JAVA認證介紹12-18

    Sun認證Java開發(fā)員考試介紹10-09

    sun認證考試:Java.io的使用01-08

    Sun Java認證考試教材教輔09-13

    sun java認證報考指南09-07

    怎樣獲得Sun Java認證05-08

    主站蜘蛛池模板: 亚洲А∨精品天堂在线| 国模和精品嫩模私拍视频| 日本精品久久久中文字幕| 热RE99久久精品国产66热| 久久国产精品久久国产精品| 亚洲精品无码久久久久久| 日本精品在线视频| 无码人妻精品一区二区三区久久久 | 精品欧美一区二区在线看片| 国产成人精品电影在线观看| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 国产精品男男视频一区二区三区 | 911亚洲精品国内自产| 精品久久久噜噜噜久久久| 午夜亚洲av永久无码精品| 国产亚洲精品无码拍拍拍色欲| 欧美精品免费在线| 999久久久免费精品国产| 日韩精品无码一区二区三区免费| 麻豆国产精品VA在线观看不卡| 国产精品婷婷午夜在线观看| 中文字幕一区二区精品区| 精品视频一区二区三区在线观看| 国产综合精品一区二区三区| 亚洲av午夜福利精品一区| 亚洲国产精品一区二区第一页免| 国模精品一区二区三区| 国产精品青草久久久久福利99| 四虎影视国产精品亚洲精品hd| 国产大片91精品免费观看不卡| 国产亚洲精品无码成人| 精品麻豆丝袜高跟鞋AV| 久久精品夜夜夜夜夜久久| 久久丫精品国产亚洲av| 久久亚洲日韩精品一区二区三区| 亚洲热线99精品视频| 中文字幕精品无码一区二区 | 国产91精品在线观看| 2022精品天堂在线视频| 国产精品多p对白交换绿帽| 国语自产少妇精品视频|