当前位置:乐求学 >

好好学习 >考研 >

C语言开发工程师选择题

C语言开发工程师选择题

1.分析如下所示C#代码,编译运行后的输出结果是( )。(选择一项)

C语言开发工程师选择题

public static void Main(string[] args)

{

int param = 2;

string position = “”;

switch (param)

{

case 1:

position = “兄长”;

break;

case 2:

position = “兄弟”;

break;

}

eLine(position);

}

a) 兄长

b) 兄弟

c) 小妹

d) 兄长兄弟

2.现有如下一段C#代码,该代码的运行结果是( )。(选择一项)

public static void Main(){

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

switch(i){

case 1:

e(ring());

break;

default:

e((i*3)ring());

}

}

}

a) 169

b) 有编译错误 没有break!!!

c) 369

d) 123

3.看以下一段程序:

e("hello world !");

eLine("friend.");

int i=0;

do

{

e("thank you !");

i++;

}while(i<2);

程序的输出结果是( )(选择一项)

a) hello world ! friend thank you !thank you !

b) hello world ! friend

thank you !thank you! Writeline 代表能换行

c) hello world ! friend. thank you ! thank you !

d) hello world !

friend. thank you !

4. using System;

class Test{

static void Main(String [] args){

int a=10,b=20,c=30;

if(a>b||b>c)

eLine(a);

else if(a

eLine(b+c);

else

eLine(c);

}

}

a) 10

b) 20

c) 50

d) 60

5. 以下C#程序:

static void Main(string[] args)

{

int val = 1;

for (int i=3;i<10;i+=2)

{

eLine(i);

}

}

运行时将输出( )。(选择一项)

a) 3

5

7

9

b) 5

7

9

c) 5

7

9

11

d) 9

6. 分析下面的代码片段,正确的输出结果是( )。(选择一项)

int i=0;

for(;i<4;i+=2){

e(i+”,”);

}

e (i);

a) 0,2

b) 0,2,4

c) 0,2,4,6

d) 0,1,2,3

7. 给定如下C#代码片段,编译运行结果是( )。(选择一项)

int i = 0, j = -1;

switch (i){

case 0,1: j=1;

case 2: j=2;

}

e (“j=”+j);

a) 程序编译出错

b) 输出:j=1

c) 输出:j=2

d) 输出:j=0

8. 在C#中,下列代码的.运行结果是( )。(选择一项)

using System;

class Test{

static void Main(string[] args){

int a=21,b=22,c=23;

if (a>b‖b>c)

eLine(++b);

else

eLine(a+b+c);

}

}

a) 22

b) 23

c) 66

d) 编译出错

9. 以下关于C#代码的说法正确的是( )。(选择一项)

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

{

switch(i)

{

case 1:

e(ring();

case 2:

e((i*2)ring();

case 3:

e((i*3)ring()

}

}

a) 有编译错误,提示case标签不能贯穿到另一个标签,不能运行 没有写Break!!!!

b) 输出149

c) 输出123246369

d) 正确运行,但没有输出

10. 针对以下的C#代码:

using System;

class A

{

static void Main()

{

int[] B = new int[10];

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

{

//空白

}

foreach (int C in B)

{

eLine (C);

}

}

}

要在控制台输出1到10的数字,空白处应填写的正确的代码为( )。(选择一项)

a) B[I]=I+1;

b) B[I]=I;

c) B[I-1]=I;

d) B[I+1]=I;

11.在C#中,下列代码的运行结果是( )(选择一项)

int a=30,b=20;

b=a;

a=10;

eLine(a);

eLine(b);

a) 10

10

b) 10

30

c) 30

20

d) 10

20

12.下列语句执行后,变量i的值为多少?( )(选择一项)

string str = @”"”Ahoy”",cried the caption. “;

string str2 = “”Ahoy”,cried the caption. “;

int I = are(str,str2);

a) false

b) -1

c) 1

d) 0

13.在开发环境中,为程序代码增加断点,快捷键为( )。(选择一项)

a) F2

b) F5

c) F8

d) F9

14.在中,( )对象的结构类似于关系数据库的结构,并在与数据库断开的情况下,在缓存中存储数据。(选择一项)

a) DataAdapter 加载数据源

b) DataSet 重载

c) DataTable

d) DataReader 读取机制

15. 下面关于数据库操作的代码,错误的是( )(选择两项)

a) SqlConnection conn = new SqlConnection();

SqlCommand comm = new SqlCommand();

uteNonQuery();

b) SqlConnection conn = new SqlConnection(“server=.;uid=sa;pwd=sa;database=db1”);

();

SqlCommand comm = new SqlCommand(“delete * from table1”, conn);

uteNonQuery();

e()

c) SqlConnection conn = new SqlConnection(“server=.,uid=sa,pwd=sa,database=db1”);

();

SqlCommand comm = new SqlCommand(“delete * from table1”);

uteNonQuery();

e();

d) SqlConnection conn = new SqlConnection(“server=.;uid=sa;pwd=sa;database=db1”);

();

SqlCommand comm = new SqlCommand(“delete * from table1”, conn);

uteNonQuery();

16.运行下面一段代码:

class Class1

{

public static int count = 0;

static Class1()

{

count++;

}

public Class1()

{

count++;

}

}

Class1 o1 = new Class1();

Class1 o2 = new Class1();

请问,t的值是多少?( )(选择一项)

a) 1

b) 2

c) 3

d) 4

17.在C#中,下列代码的运行结果是( )。(选择一项)

class A{

public void printStr(string str){

eLine(str);

}

}

class B:A{

new public void printStr(string str){

str=str+”(override)”;

eLine(str);

}

public static void Mail(string[] args){

A a=new A();

B b=new B();

tStr(“test”);

tStr(“test”);

}

}

a) test

test(override)

b) test(override)

c) test

d) test(override)

test(override)

18.分析以下C#代码,根据面向对象的多态性,代码的运行结果是( )。(选择一项)

class A{

public void F(){

e(“A”);

}

方法重载

public void F(string chr){

e(chr);

}

}

class B:A{

public void F(){

e(“B”);

}

}

public class Test{

public static void Main(string[] args){

A a = new B();

a.F();

}

}

a) B

b) A

c) AB

d) BA

  • 文章版权属于文章作者所有,转载请注明 https://m.leqiuxue.com/kywx/3kdr44.html