niusouti.com
参考答案和解析
A
更多“对于代码 long int x (1.1);编译器不会报错”相关问题
  • 第1题:

    有以下定义:“int a;long b;double X,Y;”,则以下选项中正确的表达式是( )。 A.a%(int x—y)SXB

    有以下定义:“int a;long b;double X,Y;”,则以下选项中正确的表达式是( )。

    A.a%(int x—y)

    B.a=x!=Y;

    C.(a*y)%b

    D.y=x+y=X


    正确答案:D
    选项A、C,取模运算符(%)用于计算两个整数相除所得的余数,intx-y与a*y的结果是双精度,因此不能使用取模运算符;选项B,a是属于整型变量,x、Y属于双精度变量,因此不能将x赋值给a。

  • 第2题:

    下列程序的运行结果是______。includelong func(int x){ long p;if(x==O‖x==1)return(1)

    下列程序的运行结果是______。

    include<stdio.h>

    long func(int x)

    { long p;

    if(x==O‖x==1)

    return(1);

    p=x*func(x-1);

    return(p);

    }

    main()

    { printf("%d\n",func(4));

    }


    正确答案:

    本题考查函数的循环调用。p=x*func(x-1),当x=4时,不满足if语句的条件,p=4*func(3), x=3也不满足条件,则func(3)=3*func(2),func(2)=2*func(1),x=1满足条件return(1),则输出结果为 4*3*2*1=24。

  • 第3题:

    运行以下的程序代码,结果是()。includeusing namespace std;intmain(){int x=5;int *q

    运行以下的程序代码,结果是( )。 #include<iostream> using namespace std; intmain() { int x=5; int *q=&x; int &y=x; y++; tout<<(*q)++<<end1; return 0; }

    A.5

    B.6

    C.7

    D.8


    正确答案:B

  • 第4题:

    假设某个函数的原型为:void foo( int x, int y ); 该函数分别被C编译器和C++编译器编译后在符号库中的名字是什么?


    正确答案:该函数被C编译器编译后在符号库中的名字为_foo,而C++编译器则会产生像_foo_int_int之类的名字(不同的编译器可能生成的名字不同,但是都采用了相同的机制,生成的新名字称为“mangled name”)。_foo_int_int 这样的名字包含了函数名、函数参数数量及类型信息,C++就是靠这种机制来实现函数重载的。

  • 第5题:

    Given the following code, which method declarations, when inserted at the indicated position, will not cause the program to fail compilation?()   public class Qdd1f {   public long sum(long a, long b) {  return a + b;  }   // insert new method declaration here  }  

    • A、public int sum(int a, int b) { return a + b; }
    • B、public int sum(long a, long b) { return 0; }
    • C、abstract int sum();
    • D、private long sum(long a, long b) { return a + b; }
    • E、public long sum(long a, int b) { return a + b; }

    正确答案:A,E

  • 第6题:

    变量声明时不指定类型,编译器会报错误,编译不过去


    正确答案:错误

  • 第7题:

    Java中整型包括()。

    • A、int,byte,char
    • B、int,short,long,byte,char
    • C、int,short,long,char
    • D、int,short,long,byte

    正确答案:D

  • 第8题:

    Which of the following statements are legal?()         

    • A、 long l = 4990;
    • B、 int i = 4L;
    • C、 float f = 1.1;
    • D、 double d = 34.4;
    • E、 double t = 0.9F;

    正确答案:A,D,E

  • 第9题:

    多选题
    Given: Which five methods, inserted independently at line 5, will compile?()
    A

    protected int blipvert(long x) { return 0; }

    B

    protected long blipvert(int x) { return 0; }

    C

    private int blipvert(long x) { return 0; }

    D

    private int blipvert(int x) { return 0; }

    E

    public int blipvert(int x) { return 0; }

    F

    protected long blipvert(long x) { return 0; }

    G

    protected long blipvert(int x, int y) { return 0; }


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

  • 第10题:

    判断题
    对于C6000编译器,长型(long)型数据的长度为64bit。
    A

    B


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

  • 第11题:

    单选题
    现有:  1.class Over  {  2.int dolt (long x)  {  return 3;  }      3.  }      4.  5. class Under extends Over  {      6.//insert code here      7.  }  和四个方法:  short dolt (int y)  {  return 4;  }  int dolt(long Xr long y)  {  return 4;  }      private int dolt(short y)  {  return 4;  }     protected int dolt (long x)  {  return 4;  }      分别插入到第6行,有几个可以通过编译?()
    A

      1

    B

      2

    C

      3

    D

      4


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

  • 第12题:

    单选题
    考虑下面的函数: int min(int x,int y){return xint max(int x,int y){return x>y?x:y;} 对于下面的代码: t=0; for(i=max(x,y);i>=min(x,y);i--) t+=i; 假设x=1,y=100,则可以得到函数调用的次数为()
    A

    200

    B

    201

    C

    101

    D

    102


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

  • 第13题:

    在下列源代码文件Test.java中,正确定义类的代码是( )。

    A.pblic class test { public int x=0; public test(int x) { this. x=x;} }

    B.public class Test { public int x=0; public Test(int x) { this. x=x;} }

    C.public class Test extends T1,T2{ public int x = 0; public Test(int x){ this. x = x; } }

    D.protected class Test extends T2{ public int x = 0; public Test(int x) { this. x = x; } }


    正确答案:B
    解析:本题主要考查类声明格式为[修饰符]class类名[extends父类名][implements类实现的接口列表],选项A中源文件名与程序名不相同,Java不支持多重继承所以选项C错误,选项D中类的访问权限不对,应为public。

  • 第14题:

    有如下程序: #inClude<iostream> using namespaCe std; Class Sample{ friend long fun(Sample S); publiC: Sample(10ng A.{x=a;} private: long X; }; long fun(Sample S){ if(S.x<2)return l; return S.X*fun(Sample(s.x-1)); } int main( ) { int sum=0; for(int i=0;i<6;i++) {sum+=fun(Sample(i));} Cout<<sum: return 0; } 执行这个程序的输出结果是( )。

    A.120

    B.16

    C.154

    D.34


    正确答案:C
    本题考查默认构造函数,当i=0、1时,fun(Sample(i))为1;当i=2时,fun(Sample(i)1为2;当i=3时,fun(Sample(i))为6;当i=4时,fun(Sample(i))为24;当i=5时,fun(Sample(i))为120。所以总和为l54

  • 第15题:

    以下代码中变量result的可能类型有哪些?byte b = 11;short s = 13;result = b * ++s;

    A.byte, short, int, long, float, double

    B.boolean, byte, short, char, int, long, float, double

    C.byte, short, char, int, long, float, double

    D.byte, short, char

    E.int, long, float, double


    正确答案:E
     

  • 第16题:

    阅读以下代码:  public class Test{  public static void main(){  System.out.println(“x=”+x);   } }  请问,代码运行的结果是?() 

    • A、 x
    • B、 x=x
    • C、 “x=”+5
    • D、 编译报错

    正确答案:D

  • 第17题:

    以下代码编译报错的是?()

    • A、double a = 129;
    • B、int a = 129;
    • C、short a = 129;
    • D、byte a = 129;

    正确答案:D

  • 第18题:

    考虑下面的函数: int min(int x,int y){return xint max(int x,int y){return x>y?x:y;} 对于下面的代码: t=0; for(i=max(x,y);i>=min(x,y);i--) t+=i; 假设x=1,y=100,则可以得到函数调用的次数为()

    • A、200
    • B、201
    • C、101
    • D、102

    正确答案:D

  • 第19题:

    在C语言中(以16为PC机为例),5种基本数据类型的存储空间长度的排列顺序为()。

    • A、char < int < long int <= float < double
    • B、char = int < long int <= float < double
    • C、char < int < long int <= float = double
    • D、char = int = long int <= float < double

    正确答案:A

  • 第20题:

    多选题
    Given the following code, which method declarations, when inserted at the indicated position, will not cause the program to fail compilation?()   public class Qdd1f {   public long sum(long a, long b) {  return a + b;  }   // insert new method declaration here  }
    A

    public int sum(int a, int b) { return a + b; }

    B

    public int sum(long a, long b) { return 0; }

    C

    abstract int sum();

    D

    private long sum(long a, long b) { return a + b; }

    E

    public long sum(long a, int b) { return a + b; }


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

  • 第21题:

    问答题
    假设某个函数的原型为:void foo( int x, int y ); 该函数分别被C编译器和C++编译器编译后在符号库中的名字是什么?

    正确答案: 该函数被C编译器编译后在符号库中的名字为_foo,而C++编译器则会产生像_foo_int_int之类的名字(不同的编译器可能生成的名字不同,但是都采用了相同的机制,生成的新名字称为“mangled name”)。_foo_int_int 这样的名字包含了函数名、函数参数数量及类型信息,C++就是靠这种机制来实现函数重载的。
    解析: 暂无解析

  • 第22题:

    单选题
    阅读以下代码:  public class Test{  public static void main(){  System.out.println(“x=”+x);   } }  请问,代码运行的结果是?()
    A

     x

    B

     x=x

    C

     “x=”+5

    D

     编译报错


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

  • 第23题:

    单选题
    1. class Over{   2. int doIt(long x) { return 3;}   3. }   4.   5. class Under extends Over{   6. //insert code here 7. }   和四个方法:   short doIt(int y) {return 4;}   int doIt(long x,long y){return 4;}   private int doIt(Short y){ return 4;}   protected int doIt(long x){return 4;}   分别插入到第6行,有几个可以通过编译?()
    A

    2

    B

    3

    C

    4

    D

    0

    E

    1


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

  • 第24题:

    多选题
    1. public class Blip {  2. protected int blipvert(int x) { return 0; }  3. }  4. class Vert extends Blip {  5. // insert code here  6. }  Which five methods, inserted independently at line 5, will compile?()
    A

    public int blipvert(int x) { return 0; }

    B

    private int blipvert(int x) { return 0; }

    C

    private int blipvert(long x) { return 0; }

    D

    protected long blipvert(int x, int y) { return 0; }

    E

    protected int blipvert(long x) { return 0; }

    F

    protected long blipvert(long x) { return 0; }

    G

    protected long blipvert(int x) { return 0; }


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