1. <rp id="zsypk"></rp>

      2. java基礎測試題帶答案

        時間:2021-06-11 17:13:14 試題 我要投稿

        java基礎測試題帶答案

          單選題:(每道題目2分)

        java基礎測試題帶答案

          1、下列哪個聲明是錯誤的?(B)

          A、 int i=10;

          B、 float f=1.1;     //float f=1.1f

          C、 double d=34.4;

          D、 byte b=127;

          long類型的數據加后綴L或者l

          float類型的數據加后綴F或者f

          整數默認是int類型

          浮點數默認是double類型

          2、下面哪個不是java中的關鍵字?(C)

          A、public

          B、 true

          C、 main

          D、 class

          3、下面程序哪個語句是正確的(C)

          A、 byte a=0,b=3; byte c =a+b;//a+b的類型為int

          B、 short s =23; s=s+12;

          //s+12底層是轉成int進行相加,所以結果為int。

          C、 short s=23; s+=12;  //相當于s=(short)(s+12)

          D、 float f = 23+23.23;  //23+23.23的結果為double

          4、下面程序執行的結果是?(B)

          class  Test

          {

          public static  void  main(String[] args)

          {

          System.out.println(“”+‘a’+1);

          }

          }

          A、98

          B、 a1

          C、 971

          D、 197

          //空串放前相當于字符串的拼接,空串放后,‘a’+1,先做運算,再與空串進行拼接,byte,short,char可以自動轉為int,

          5、下面程序執行的結果是?(B)

          int i =100;

          while(true)

          {

          if (i++ > 100)   //i先計算在自加

          {

          break;

          }

          System.out.println(i);

          }

          A、 100

          B、 101

          C、 102

          D、 報錯

          6、 下面程序的運行結果是   ( D )

          int a=3,b=1;

          if(a==b)

          {

          System.out.println("a="+a);

          }

          A、 a=1

          B、 a=3

          C、 編譯錯誤

          D、 正常運行但沒有輸出

          7、下面程序的運行后,結果正確的是:(B)

          inta=1,b=2;

          intc=(a+b>3?a++:++b); //a=1,b=3,c=3

          A、 a=2,b=3

          B、 a=1,b=3

          C、 a=1,b=2

          D、 c=2

          8、下面程序的運行結果(B)

          classDemo

          {

          public static int fun(int c)

          {

          return c+=2;

          }

          public static void main(String[] args)

          {

          int temp = fun(2);

          System.out.println(temp);

          }

          }

          A、 2

          B、 4

          C、 6

          D、 8

          9、下面數組定義錯誤的是(C)

          A、 int [] arr ={23,45,65,78,89};  //靜態初始化

          B、 int [] arr=new int[10] ;        //動態初始化

          C、 int [] arr=new int[4]{3,4,5,6};

          D、 int [] arr={‘a’, 23 , 45 , 6};

          //‘a’可以自動轉為int,

          10、下面程序執行的'結果是?(D )

          int x=1,y=1;

          if(x++==2& ++y==2)

          //x=2,y=2,&與&&的結果相同但是&不具有短路效果

          {

          x=7;

          }

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

          A、 x=1 y=2

          B、 x=7 y=1

          C、 x=7 y=2

          D、 x=2 y=2

          11、下面不屬于基本數據類型的是(D)

          A、 int

          B、 double

          C、 long

          D、 int[] //引用類型

          12、下面程序執行的結果是?( C)

          booleanb=true;

          if(b=false)         //將false賦值給b,則b=false

          {

          System.out.println("a");

          }

          elseif(b)

          {

          System.out.println("b");

          }

          elseif(!b)

          {

          System.out.println("c");

          }

          else

          {

          System.out.println("d");

          }

          A、a

          B、b

          C、c

          D、d

          13、下面程序執行的結果是?(D)

          intx=2,y=3;

          switch(x)

          {

          default:

          y++;    //y=4,但是沒有break,程序繼續向下執行

          case 3:

          y++;

          case 4:

          y++;

          }

          Sysetem.out.println("y="+y);

          A、 3

          B、 4

          C、 5

          D、 6

          14、下面程序執行的結果

          for(int  i=1;i<=10;i++)

          {

          if (i%3==0)

          {

          continue;    //continue跳出本次循環

          }

          System.out.println(“java基礎班”);

          }

          在屏幕上打印幾次“java基礎班”?( C )

          A、 5

          B、 6

          C、 7

          D、 8

          15.閱讀下面代碼段:

          classDemo

          {

          public static void main (String[] args)

          {

          int[] arr = new int[10];

          System.out.println(arr[1]);

          }

          }

          執行結果正確的說法是( C )

          A、 編譯時將產生錯誤

          B、 編譯時正確,運行時將產生錯誤

          C、 輸出零

          D、 輸出空

          16 .和下面代碼能完成相同的選項是(B)

          int i=1;

          intsum=0;

          while(i<=100)

          {

          if(i%2==0)

          {

          sum=sum+i;

          }

          i++;

          }

          A、 for (int x=1; x<=100;x++){ sum=sum+x;}

          B、 for (int x =0; x<=100;x+=2){ sum=sum+x;}  //偶數求和

          C、 for (int x =1; x<=100;x+=2){ sum=sum+x;}  //奇數求和

          D.上述全對

          17、以下代碼輸出是(  D )

          int i=0;

          int sum=0;

          while(i<=10)

          {

          i++;

          if( i%2!=0 )

          continue;

          sum+=i;

          }

          System.out.println(sum);    //sum=2+4+6+8+10

          A、 55

          B、 45

          C、 35

          D、 30

          18、給出下列代碼片段:

          if ( x> 0 ) { System.out.println(“Hello”); }

          else if (x >-3 ) { System.out.pirntln ( “I am Tom”); }

          else {System.out.println (“How are you?”); }

          請問將打印字符串 “How are you ?”的x的范圍是( C)

          A、  x>0

          B、  x > -3

          C、  x <= -3

          D、  x <=0 x="">-3

          19、下列代碼執行的結果為( A )

          classDemo

          {

          public static void main(String[] args)

          {

          int num =max(43,34);     //num=43

          System.out.println(num);

          }

          public static int max(int a,int b)

          {

          returna>b?a:b;

          }

          }

          A、 43

          B、 23

          C、 77

          D、 9

          20、下面程序執行的結果是( A )

          classDemo

          {

          public static void main(String [] args)

          {

          int a=10;

          if(a++>10)

          {

          a=20;

          }

          System.out.println(a);

          }

          }

          A、 11

          B、 12

          C、 20

          D、 21

        【java基礎測試題帶答案】相關文章:

        java基礎測試題及答案04-12

        java基礎面試題及答案04-20

        平安基礎測試題及答案04-19

        基礎會計測試題及答案04-04

        java基礎教程試題答案04-12

        會計基礎測試題及答案解析03-17

        我的呼吁基礎測試題及答案04-03

        《我的呼吁》基礎測試題及答案06-13

        心理壓力測試題帶答案04-05

        99热这里只有精品国产7_欧美色欲色综合色欲久久_中文字幕无码精品亚洲资源网久久_91热久久免费频精品无码
          1. <rp id="zsypk"></rp>

          2. 日韩亚洲欧美另类一区 | 亚洲最大天堂在线 | 亚洲日韩欧美另类国产 | 日本中文字幕二区区高清 | 亚洲男人aⅴ第一成肉网 | 台湾国产1区2区 |