JavaEE測(cè)試題

社招測(cè)試題(共計(jì)20題,5分/題,總分100分,建議考試時(shí)長(zhǎng):60分鐘,及格線60分)

  1. 下面哪個(gè)語(yǔ)句不會(huì)產(chǎn)生編譯錯(cuò)誤?( )
    A. float a =2.0;
    B. char c =”a”;
    C. byte b =25;
    D. boolean d=0;

  2. 下面程序執(zhí)行的結(jié)果是?()
    public class Test()
    {
    public static void main(String[] args)
    {
    System.out.println(“”+’a’+1);
    }
    }
    A. 98
    B. a1
    C. 971
    D. 197

  3. 下面程序執(zhí)行的結(jié)果是?()
    int i = 100;
    while(true)
    {
    If ( i++ > 100 )
    break;
    System.out.println(i);
    }
    A. 100
    B. 101
    C. 102
    D. 103

  4. 下面程序執(zhí)行的結(jié)果是?()
    int a=2;

switch(a)
{
case 1:
a+=1;
break;
case 2:
a+=2;
case 3:
a+=3;
break;
case 4:
a+=4;
break;
default:
a=0;
}
System.out.println(a);
A. 5
B. 6
C. 7
D. 8

  1. 下面程序的運(yùn)行結(jié)果是 ( )
    int a=3, b=1;
    if(a==b)
    System.out.println("a="+a);
    A. a=1
    B. a=3
    C. 編譯錯(cuò)誤
    D. 正常運(yùn)行但沒(méi)有輸出

  2. 下面程序的運(yùn)行后,a,b,c的值正確的是:()
    int a=1,b=2;
    int c=(a+b>3?a++:++b);
    A. a=2,b=3
    B. a=1,b=3
    C. a=1,b=2
    D. c=2

  3. 下面程序的運(yùn)行結(jié)果( )
    public class Demo
    {
    public static int fun(int c)
    {
    return c+=2;
    }
    public static void main(String[] args)
    {
    int temp=fun(2); //4
    System.out.println(temp);

    }
    }
    A. 2
    B. 4
    C. 6
    D. 8

  1. 下面程序的運(yùn)行結(jié)果,哪個(gè)是正確的 ()
    int b=1;
    while(++b<3)
    System.out.println("LOOP");
    A. 程序?qū)?huì)進(jìn)入死循環(huán)導(dǎo)致無(wú)輸出
    B. 輸出一次LOOP
    C. 會(huì)輸出多次LOOP
    D. 程序中含有編譯錯(cuò)誤

  2. 下面數(shù)組定義錯(cuò)誤的是()
    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(chǎn)’, 23 , 45 , 6};

  3. 下面程序執(zhí)行的結(jié)果是?( )
    int x =1,y=1;
    if(x++==2 & ++y==2) //false,x=2 & true,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

  4. 在Java中,以下程序編譯運(yùn)行后的輸出結(jié)果為( )。
    public class Test {
    int x, y;
    Test(int x, int y) {
    this.x = x;
    this.y = y;
    }
    public static void main(String[] args) {
    Test pt1, pt2;
    pt1 = new Test(3, 3);
    pt2 = new Test(4, 4);
    System.out.print(pt1.x + pt2.x);
    }
    }
    A. 6
    B. 3 4
    C. 8
    D. 7

請(qǐng)問(wèn)以下代碼的運(yùn)行結(jié)果:()
public class Student{
public Student(){
System.out.println(“a”);
}
public Student(){
System.out.println(“b”);
}
public void show(){
System.out.println(“c”);
}
}
public class Demo{
public static void main(String[] args){
Student stu = new Student();
stu.show();
}
}

A、 a
B、 b
C、 c
D、 編譯出錯(cuò)

  1. 有如下類定義:
    public class Student {
    public Student(){
    System.out.println("a");
    }
    public Student(String name){
    _________________ ;
    System.out.println(name);
    }
    public static void main(String[] args){
    Student stu =____________ ;
    }
    }
    請(qǐng)問(wèn)以下哪些選項(xiàng)依次填入橫線處會(huì)使程序打印字符串“a” ( )

A.this(name);
B.new Student();
C.new Student(“Java”);
D.this();
E.System.out.println(“Java”);

  1. 對(duì)字符串”ababcdabcdefg”使用indexOf(‘a(chǎn)’)和lastIndexOf(‘a(chǎn)’),的運(yùn)行結(jié)果是( )
    A. 1,1
    B. 0,6
    C. 0,0
    D. 1,6

  2. 下面程序的運(yùn)行結(jié)果是什么( )
    public static void main(String[] args){
    String s1 = “abc”;
    String s2 = “xyz”;
    show(s1,s2);
    System.out.println(s1+”-----”+s2);
    }
    static void show(String s1,String s2){
    s1 = s2+s1+”Q”;
    s2 = “W”+s1;
    }
    A. abc-----xyz
    B. xyzabcQ-----xyzWabc
    C. xyzabcQ---- xyzabcQWabc
    D. xyzQ----Wabc

  3. 將字符串轉(zhuǎn)成字符數(shù)組的方法是( )
    A. toString()
    B. toCharArray()
    C. toUpperCase()
    D. toLowerCase()

  4. 下面程序的運(yùn)行結(jié)果是( )
    public static void main(String[] args){
    StringBuffer sb = new StringBuffer();
    sb.append("qq").append("ww");
    show(sb,"ss");
    System.out.println(sb.length());
    }
    static void show(StringBuffer sb,String str){
    sb.append(str);
    }
    A. 4
    B. 2
    C. 6
    D. 0

  5. 請(qǐng)問(wèn)下面程序的執(zhí)行結(jié)果( )
    public class Test{
    public static void main(String[] args){
    List<String> list = new ArrayList<>();
    list.add("aaa");
    list.add("bbb");
    list.add("ccc");
    list.add(10);
    for(int i=0;i<list.size;i++){
    System.out.println(list.get(i));
    }
    }
    }
    A、 [aaa, bbb, ccc, 10]
    B、 [10, ccc, bbb, aaa]
    C、 編譯錯(cuò)誤
    D、 運(yùn)行時(shí)異常

  6. 根據(jù)題目補(bǔ)全代碼。將自定義Student對(duì)象存到ArrayList集合中,要求使用普通for循環(huán)進(jìn)行遍歷( )
    public class Student {
    private String name;
    public Student() {
    super();
    }
    public Student(String name) {
    super();
    this.name = name;
    }
    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
    }
    public class ArrayListTest {
    public static void main(String[] args) {
    ArrayList<Student> list = new ArrayList<Student>();
    list.add(new Student("Jim"));
    list.add(new Student("Tom"));
    list.add(new Student("LiLei"));

    for (int i = 0; _____ ; i++) {
    Student s = ______;
    System.out.println(s.getName());
    }
    }
    A: i < list.size()
    B: i<list.length()
    C: list.next();
    D: list.get(i);
    E: list.hasNext();

  7. 關(guān)于StringBuffer和StringBuilder說(shuō)法正確的是( )
    A. StringBuffer和StringBuilder的方法不同
    B. StringBuffer和StringBuilder都是線程安全的
    C. StringBuffer是線程安全的,StringBuilder不是線程安全的
    D. StringBuffer不是線程安全的,StringBuilder是線程安全的

  8. 下面程序運(yùn)行的結(jié)果是( )
    String str = “abcdefg”;
    str.substring(0,2);
    System.out.println(str);

A. ab
B. abc
C. abcdefg
D. 出現(xiàn)下標(biāo)越界異常

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1. Java基礎(chǔ)部分 基礎(chǔ)部分的順序:基本語(yǔ)法,類相關(guān)的語(yǔ)法,內(nèi)部類的語(yǔ)法,繼承相關(guān)的語(yǔ)法,異常的語(yǔ)法,線程的語(yǔ)...
    子非魚_t_閱讀 34,624評(píng)論 18 399
  • Java經(jīng)典問(wèn)題算法大全 /*【程序1】 題目:古典問(wèn)題:有一對(duì)兔子,從出生后第3個(gè)月起每個(gè)月都生一對(duì)兔子,小兔子...
    趙宇_阿特奇閱讀 2,069評(píng)論 0 2
  • 【程序1】 題目:古典問(wèn)題:有一對(duì)兔子,從出生后第3個(gè)月起每個(gè)月都生一對(duì)兔子,小兔子長(zhǎng)到第三個(gè)月后每個(gè)月又生一對(duì)兔...
    葉總韓閱讀 5,223評(píng)論 0 41
  • 一、 1、請(qǐng)用Java寫一個(gè)冒泡排序方法 【參考答案】 public static void Bubble(int...
    獨(dú)云閱讀 1,494評(píng)論 0 6
  • 自己的價(jià)值不是靠別人的喜歡實(shí)現(xiàn)
    Endeavorer閱讀 273評(píng)論 0 0

友情鏈接更多精彩內(nèi)容