1. public class ArrayTest {  2. public static void main (String[]args)  {  3. float f1[], f2[];  4. f1 = new float [10];  5. f2 = f1;  6. System.out.printIn (“f2[0]=” + f2[0]);  7.  }  8. }   What is the result?()  A、 It prints f2[0] = 0.0B、 It prints f2

题目

1. public class ArrayTest {  2. public static void main (String[]args)  {  3. float f1[], f2[];  4. f1 = new float [10];  5. f2 = f1;  6. System.out.printIn (“f2[0]=” + f2[0]);  7.  }  8. }   What is the result?()  

  • A、 It prints f2[0] = 0.0
  • B、 It prints f2[0] = NaN
  • C、 An error at line 5 causes compile to fail.
  • D、 An error at line 6 causes compile to fail.
  • E、 An error at line 6 causes an exception at runtime.

相似考题
参考答案和解析
正确答案:A
更多“1. public class ArrayTest {  2. public static void main (String[]args)  {  3. float f1[], f2[];  4. f1 = new float [10];  5. f2 = f1;  6. System.out.printIn (“f2[0]=” + f2[0]);  7.  }  8. }   What is the result?()  A、 It prints f2[0] = 0.0B、 It prints f2[”相关问题
  • 第1题:

    publicclassArrayTest{publicstaticvoidmain(Stringargs){floatf1,f2;f1=newfloat[10];f2=f1;System.out.printIn(f2[0]=”+f2[0]);}}Whatistheresult?()

    A.Itprintsf2[0]=0.0

    B.Itprintsf2[0]=NaN

    C.Anerroratline5causescompiletofail.

    D.Anerroratline6causescompiletofail.

    E.Anerroratline6causesanexceptionatruntime.


    参考答案:A

  • 第2题:

    有如下程序includeusing namespace std;class base{public:virtual void f1(){cout<<

    有如下程序 #include<iostream> using namespace std; class base { public: virtual void f1() { cout<<"F1Base"; } virtual void f2() { cout<<"F2Base"; } }; class derive:public base { void f1() { cout<<"F1 Derive"; } void f2(int x) { cout<<"F2 Derive"; } }; int main() { base obj1,*p; derive obj2; p=& obj2; p->f1(); p->f2(); return (); ) 执行后的输出结果是( )。

    A.F1Derive F2Base

    B.F1Derive F2Derive

    C.F1Base F2Base

    D.F1Base F2Derive


    正确答案:A

  • 第3题:

    以下程序的输出结果是( )。 include void main() {int f,f1,f2,i; f1=0;f2=1; printf("%

    以下程序的输出结果是( )。 include<stdio.h> void main() {int f,f1,f2,i; f1=0;f2=1; printf("%d%d",f1,f2); for(i=3;i<=5;i++) {f=-f1+f2,printf("%d",f); f2=f1;f1=f; } printf("\n"); }


    正确答案:0 1 112
    0 1 112 解析:在主函数中定义了整型变量f1和f2,并把其值赋为0和1,在屏幕上输出。然后在第一次运行for循环语句时,变量f的值等于1,把其值输出,把变量f1的值0赋给变量f2,变量f的值1赋给n,在执行第二次for循环语句时,变量f的值等于1,把此值输出。然后再把变量f1的值1赋给变量f2,变量f的值1赋给f1,在执行第三次for循环语句时,变量f的值等于2,把此值输出。所以程序运行后的结果为0 1 112。

  • 第4题:

     public class ArrayTest {   public static void main (Stringargs) {   float f1, f2;   f1 = new float [10];  f2 = f1;   System.out.printIn (“f2[0]=” + f2[0]);   }  }   What is the result?()

    • A、 It prints f2[0] = 0.0
    • B、 It prints f2[0] = NaN
    • C、 An error at line 5 causes compile to fail.
    • D、 An error at line 6 causes compile to fail.
    • E、 An error at line 6 causes an exception at runtime.

    正确答案:A

  • 第5题:

    1. public class A {  2. void A() {  3. System.out.println(“Class A”);  4. }  5. public static void main(String[] args) {  6. new A();  7. }  8. }  What is the result?()  

    • A、 Class A
    • B、 Compilation fails.
    • C、 An exception is thrown at line 2.
    • D、 An exception is thrown at line 6.
    • E、 The code executes with no output.

    正确答案:E

  • 第6题:

    1. public class ForBar  {  2. public static void main(String []args)   {  3.   int i = 0, j = 5;  4. tp: for (;;)  {  5. i ++;  6. for(;;)  7. if(i > --j) break tp;  8. }  9. system.out.printIn(“i = ” + i + “, j = “+ j);  10. }  11. }   What is the result?()  

    • A、 The program runs and prints “i=1, j=0”
    • B、 The program runs and prints “i=1, j=4”
    • C、 The program runs and prints “i=3, j=4”
    • D、 The program runs and prints “i=3, j=0”
    • E、 An error at line 4 causes compilation to fail.
    • F、 An error at line 7 causes compilation to fail.

    正确答案:A

  • 第7题:

    Iff1(t)←→F1(jω),f2(t)←→F2(jω),Then()

    • A、f1(t)*f2(t)←→F1(jω)F2(jω)
    • B、f1(t)+f2(t)←→F1(jω)F2(jω)
    • C、f1(t)f2(t)←→F1(jω)F2(jω)
    • D、f1(t)/f2(t)←→F1(jω)/F2(jω)

    正确答案:A

  • 第8题:

    public class test {   public static void add3 (Integer i){  int val = i.intValue ( );   val += 3;   i = new Integer (val);    }     public static void main (String args [ ] )  { Integer i = new Integer (0);    add3 (i);   system.out.printIn (i.intValue ( ) );   }    }   What is the result?()

    • A、 Compilation will fail.
    • B、 The program prints “0”.
    • C、 The program prints “3”.
    • D、 Compilation will succeed but an exception will be thrown at line 3.

    正确答案:B

  • 第9题:

    单选题
    1. public class X {  2. public static void main (String[]args)   {  3. int [] a = new int [1]  4. modify(a);  5. System.out.printIn(a[0]);  6. }  7.    8. public static void modify (int[] a)  {  9.   a[0] ++;  10.    } 11. }       What is the result?()
    A

     The program runs and prints “0”

    B

     The program runs and prints “1”

    C

     The program runs but aborts with an exception.

    D

     An error “possible undefined variable” at line 4 causes compilation to fail.

    E

     An error “possible undefined variable” at line 9 causes compilation to fail.


    正确答案: D
    解析: 暂无解析

  • 第10题:

    单选题
    1. public class ArrayTest {  2. public static void main (String[]args)  {  3. float f1[], f2[];  4. f1 = new float [10];  5. f2 = f1;  6. System.out.printIn (“f2[0]=” + f2[0]);  7.  }  8. }   What is the result?()
    A

     It prints f2[0] = 0.0

    B

     It prints f2[0] = NaN

    C

     An error at line 5 causes compile to fail.

    D

     An error at line 6 causes compile to fail.

    E

     An error at line 6 causes an exception at runtime.


    正确答案: A
    解析: 暂无解析

  • 第11题:

    单选题
    设f1(x),f2(x)是二阶线性齐次方程y″+p(x)y′+q(x)y=0的两个特解,则c1f1(x)+c2f2(x)(c1,c2是任意常数)是该方程的通解的充要条件为(  )。
    A

    f1(x)f2′(x)-f2(x)f1′(x)=0

    B

    f1(x)f2′(x)+f1′(x)f2(x)=0

    C

    f1(x)f2′(x)-f1′(x)f2(x)≠0

    D

    f1′(x)f2(x)+f2(x)f1(x)≠0


    正确答案: B
    解析:
    要使c1f1(x)+c2f2(x)是方程y″+p(x)y′+q(x)y=0的通解,则须满足f1(x),f2(x)线性无关,即ψ(x)=f1(x)/f2(x)≠k(k为常数)。则ψ′(x)=[f1′(x)f2(x)-f1(x)f2′(x)]/f22(x)≠0,即f1′(x)f2(x)-f1(x)f2′(x)≠0。

  • 第12题:

    单选题
    public class ArrayTest {   public static void main (Stringargs) {   float f1, f2;   f1 = new float [10];  f2 = f1;   System.out.printIn (“f2[0]=” + f2[0]);   }  }   What is the result?()
    A

     It prints f2[0] = 0.0

    B

     It prints f2[0] = NaN

    C

     An error at line 5 causes compile to fail.

    D

     An error at line 6 causes compile to fail.

    E

     An error at line 6 causes an exception at runtime.


    正确答案: D
    解析: 暂无解析

  • 第13题:

    C 程序写运行结果。

    class A

    {

    public:

    void f1()

    {

    printf("A::f1\r\n");

    }

    virtual void f2()

    {

    printf("A::f2\r\n");

    }

    void callfunc()

    {

    printf("A::callfunc\r\n");

    f1();

    f2();

    }

    };

    class B :public A

    {

    public:

    void f1()

    {

    printf("B::f1\r\n");

    }

    void f2()

    {

    printf("B::f2\r\n");

    }

    void callfunc()

    {

    printf("B::callfunc\r\n");

    f1();

    f2();

    }

    };

    int main()

    {

    B *pB=new B;

    pB->callfunc();

    A *pA=pB;

    pA->callfunc();

    return 0;

    }


    正确答案:
     

  • 第14题:

    有如下程序includeusing nameSpace std;class base{public:vinual void f1() { cout<

    有如下程序 #include<iostream> using nameSpace std; class base { public: vinual void f1() { cout<<"F1 Base"; } virtual void f2() { cout<<"F2Base"; } }; class derive:public base { void f1() { cout<<"F1Derive"; } void f2(int x) { cout<<"F2Derive"; } }; int main() { base obj1,*p; derive obj2; p=&obj2; p—>f1(); p—>f2(); return 0; } 执行后的输出结果是

    A.F1Derive F2Base

    B.F1Derive F2Derive

    C.F1Base F2Base

    D.F1Base F2Derive


    正确答案:A
    解析:本题主要考查C++中虚函数机制及其继承过程中的要点。虚函数在基类中加关键字virtual声明,在派生类中重新定义;如果派生类没有覆盖虚函数,则程序执行中将会执行基类的虚函数版本。题目程序中,建立了基类base,其内函数voidf1()和voidf2()均被声明为虚函数,并在调用时会显式的发出声明。派生类derive利用public方式继承基类base,并覆盖其基类base中的虚函数f1();对于base中的虚函数f2(),由于派生类derive中的同名函数f2()中带有参数intx,因此被编译器认为是函数重载,而不作虚函数覆盖处理,因此实际上派生类derive中包含两个f2()函数,一个不带参数,调用时执行基类base中的f2()函数版本,一个带参数intx,调用时执行重载后的版本。题目main()函数中,定义了基类对象。obj1和基类指针*p,同时定义了派生类对象。obj2。p指向。obj2时:p—>f1()函数调用执行派生类覆盖后的版本,输出D1:p->f2()由于不带参数,因此执行未经派生类覆盖的函数版本,即基类base中的f1()函数版本。

  • 第15题:

    数字信号B=1时,图示两种基本门的输出分別为:

    (A) F1=A,F2 =1 (B)F1=1,F2 =A
    (C)F1=1,F2 =0 (D) F1=0,F2 =A


    答案:B
    解析:
    解:选B。 第一个为或门,第二个为与门。

  • 第16题:

    public class ArrayTest {  public static void main(String[] args) {  float fl[], f2[];  fl = new float[10];  f2 = f1;  System.out.println(“f2[0]= “ + f2[0]);  }  }  What is the result?()  

    • A、 It prints f2[0] = 0.0.
    • B、 It prints f2[0] = NaN.
    • C、 An error at line 5 causes compile to fail.
    • D、 An error at line 6 causes compile to fail.
    • E、 An error at line 6 causes an expectation at runtime.

    正确答案:A

  • 第17题:

    1. public class X {  2. public static void main (String[]args)   {  3. int [] a = new int [1]  4. modify(a);  5. System.out.printIn(a[0]);  6. }  7.    8. public static void modify (int[] a)  {  9.   a[0] ++;  10.    } 11. }       What is the result?()

    • A、 The program runs and prints “0”
    • B、 The program runs and prints “1”
    • C、 The program runs but aborts with an exception.
    • D、 An error “possible undefined variable” at line 4 causes compilation to fail.
    • E、 An error “possible undefined variable” at line 9 causes compilation to fail.

    正确答案:B

  • 第18题:

    public class Test {  private static float[] f = new float[2];  public static void main(String args[]) {  System.out.println(“f[0] = “ + f[0]);  }  }   What is the result?()  

    • A、 f[0] = 0
    • B、 f[0] = 0.0
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:B

  • 第19题:

    public class test (      private static int j = 0;  private static boolean methodB(int k) (  j += k;  return true;  )  public static void methodA(int  i)(  boolean b:     b = i < 10 | methodB (4);  b = i < 10 || methodB (8);  )  public static void main (String args[])(   methodA (0);  system.out.printIn(j);  )  )   What is the result?()  

    • A、 The program prints “0”
    • B、 The program prints “4”
    • C、 The program prints “8”
    • D、 The program prints “12”
    • E、 The code does not complete.

    正确答案:B

  • 第20题:

    单选题
    有以下程序:#include main(){ int x[]={8,2,6,12,5,15},f1,f2; int *p=x; f1=f2=x[0]; for(;p {  if(f1  if(f2>*p)f2=*p; } printf("%d,%d",f1,f2);}程序的运行结果是(  )。
    A

    15,2

    B

    15,15

    C

    2,15

    D

    8,8


    正确答案: A
    解析:
    本题求数组的最大值和最小值,首先把数组x首地址的值赋给指针p,故*p初始值为8,而p是地址值,p+1相当于数组中下一元素的地址,在for循环,是求数组x对应的最大值和最小值,f1为最大值,f2为最小值。因此输出为15和2。答案选择A选项。

  • 第21题:

    单选题
    public class ArrayTest {  public static void main(String[] args) {  float fl[], f2[];  fl = new float[10];  f2 = f1;  System.out.println(“f2[0]= “ + f2[0]);  }  }  What is the result?()
    A

     It prints f2[0] = 0.0.

    B

     It prints f2[0] = NaN.

    C

     An error at line 5 causes compile to fail.

    D

     An error at line 6 causes compile to fail.

    E

     An error at line 6 causes an expectation at runtime.


    正确答案: B
    解析: 暂无解析

  • 第22题:

    单选题
    public class test {  public static void add3 (Integer i)  int val = i.intValue ( );  val += 3;  i = new Integer (val);  } public static void main (String args [ ] )  {  Integer  i = new Integer (0);  add3 (i);  system.out.printIn (i.intValue ( )  );  } What is the result?()
    A

     Compilation will fail.

    B

     The program prints “0”.

    C

     The program prints “3”.

    D

     Compilation will succeed but an exception will be thrown at line 3.


    正确答案: C
    解析: 暂无解析

  • 第23题:

    单选题
    public class test (      private static int j = 0;  private static boolean methodB(int k) (  j += k;  return true;  )  public static void methodA(int  i)(  boolean b:     b = i < 10 | methodB (4);  b = i < 10 || methodB (8);  )  public static void main (String args[])(   methodA (0);  system.out.printIn(j);  )  )   What is the result?()
    A

     The program prints “0”

    B

     The program prints “4”

    C

     The program prints “8”

    D

     The program prints “12”

    E

     The code does not complete.


    正确答案: B
    解析: 暂无解析