给定如下Java代码片段,编译运行时,结果是() int [ ] a = {1,2,3,4,5}; for (int count = 0 ; count<5; count++) System.out.print(a[count++]) ;
A.运行时出现异常
B.输出:12345
C.输出:135
D.输出:24
第1题:
下面程序的功能是统计用0至9之间的不同的数字组成的三位数的个数。main(){ int i,j,k,count=0;for(i=1;i<=9;i++)for(j=0;j<=9;j++)if(【】)continue;else for(k=0;k<=9;k++)if(【】)count++;printf("%d",count);}
第2题:
下面程序的运行结果是【 】。
inChlde<iOStream>
using namespace std;
class count
{
static int n;
public:
count()
{
n++;
}
static int test()
{
for(int i=0:i<4;i++)
n++;
return n;
}
};
int count::n=0;
int main()
{
cout<<COUnt::test()<<" ";
count c1, c2;
cout<<count::test()<<end1;
return 0;
}
第3题:
下面程序的正确输出是( )。 public class Hello { public static void main(String args[]) { int count, xPos=25; for ( count=1; count<=10; count++ ) { if ( count==5 ) break; System.out.println(count ); xPos += 10; } } }
A.1 2 3 4
B.1 3 4
C.编译错误
D.以上都不是
第4题:
下面C程序段中count++语句执行的次数为(64)。
for(int i=1;i<=11;i*=2)
for(int j=1;j<=i;j++)
count++:
A.15
B.16
C.31
D.32
第5题:
A.int count = args.length;
B.int count = args.length-1;
C.int count=0; while(args[count]!=null) count++;
D.int count=0;while (!(args[count].equals(“”))) count++;
第6题:
有如下程序:
include<iostream>
using namespace std;
class pumpkin{
public:
pumpkin(){++count;}
~pumpkin(){--count;}
static void total_count(){
cout<<count<<"pumpkin(s)"<<end1;
}
private:
static int count;
};
int pumpkin::count=0;
int main(){
pumpkin p1[10];
pumpkin::total_count();
return 0;
}
这个程序的输出结果是______。
第7题:
int Calc(unsigned int x)
{
int count=0;
while(x)
{
printf("x=%i\n",x);
count++;
x=x&(x-1);
}
return count;
}
问 Calc(9999)的值是多少。
第8题:
有如下程序: #include<iostream> using namespace std; class Toy{ public: Toy(char*_n){strcpy(name,_n);count++;} ~Toy(){count--;} char*GetName( ){return name;} static int getCount( ){return count;} private: char name[10]; static int count; }; int Toy::count=0: int main( ){ Toy tl("Snoopy"),t2("Mickey"),t3("Barbie"); cout<<t1.getCount( )<<endl; return 0; } 程序的输出结果是
A.1
B.2
C.3
D.运行时出错
第9题:
程序段intcount=0;char*s=”ABCD”;while(*s!=’/0’){s++;count++;}执行后count=()。
4
略
第10题:
int[]my_Array; my_Array=newint[5]; for(intcount=0;count<=5;count++)System.out.println(my_Array[count]); 以上Java代码运行的结果是()。
第11题:
<%! int count = 0; %><% if ( request.getSession(false) == null ) count++; %>
<%@ int count = 0; %>. <% if ( request.getSession(false) == null ) count++; %>
<% int count = 0;. if ( request.getSession(false) == null ) count++; %>
<%@ int count = 0;. if ( request.getSession(false) == null ) count++; %>
<%! int count = 0;. if ( request.getSession(false) == null ) count++; %>
第12题:
不能通过编译
输出: count 1 = 10 count 2 = 9
输出: count 1 = 9 count 2 = 9
第13题:
如下程序的输出结果是______。
include<iostream>
using namespace std;
class pumpkin{
public:
pumpkin( ){++count;}
~pumpkin( ){--eount;}
static void total_count( ){cout<<count<<"pumpkin(s)"<<endl;}
private:
static int count;
};
int pumpkin::count=0;
int main( ){
pumpkin pl[10];
pumpkin::total_count( );
return 0;
}
第14题:
( 27 )有如下程序:
#include<iostream>
using namespace std;
class MyClass{
public:
MyClass(){++count;}
~MyClass(){--count;}
static int getCount(){return count;}
private:
static int count;
};
int MyClass::count=0;
int main(){
MyClass obj;
cout<<obj.getCount();
MyClass*ptr=new MyClass;
cout<<MyClass::getCount();
delete ptr;
cout<<MyClass::getCount();
return 0;
}
程序的输出结果是
A ) 121
B ) 232
C ) 221
D ) 122
第15题:
( 27 )有如下程序:
#include <iostream>
using namespace std;
class Toy{
public:
Toy(char* _n) { strcpy (name,_n); count++;}
~Toy(){ count--; }
char* GetName(){ return name; }
static int getCount(){ return count; }
private:
char name[10];
static int count;
};
int Toy::count=0;
int mail(){
Toy t1("Snoopy"),t2("Mickey"),t3("Barbie");
cout<<t1.getCount()<<endl;
return 0;
}
运行时的输出结果是
A ) 1
B ) 2
C ) 3
D )运行时出错
第16题:
从键盘上输入XXYYZZXYZWXP和X,以下程序的输出结果是【 】。
include<iostream.h>
include<string.h>
void main(){
char*str,ch;
int count=0,pos;
cin>>str>>ch;
pos=strlen(str)-1;
while(pos>=0){
if((str[pos])=ch)count++;
pos--;
}
cout<<"count="<<count;
}
第17题:
Fordebuggingpurposes,youneedtorecordhowmanytimesagivenJSPisinvokedbeforetheuser’ssessionhasbeencreated.TheJSP’sdestroymethodstoresthisinformationtoadatabase.WhichJSPcodesnippetkeepstrackofthiscountforthelifetimeoftheJSPpage?()
A.<%!intcount=0;%><%if(request.getSession(false)==null)count++;%>
B.<%@intcount=0;%>.<%if(request.getSession(false)==null)count++;%>
C.<%intcount=0;.if(request.getSession(false)==null)count++;%>
D.<%@intcount=0;.if(request.getSession(false)==null)count++;%>
E.<%!intcount=0;.if(request.getSession(false)==null)count++;%>
第18题:
有如下程序:
#include<iostream>
using namespace std;
class Toy{
public:
Toy(char*_n){strcpy(name,_n);count++;}
~Toy()}count--;}
char*GetName(){return name;}
static int getCount(){return count;}
private:
char name[10];
static int count;
};
int Toy::count=O:
int main(){
Toy tl(“Snoopy”),t2(“Mickey”),t3(“Barbie”);
cout<<t1.getCount()<<endl;
return O:
}
运行时的输出结果是
A.1
B.2
C.3
D.运行时出错
第19题:
给定一个Java程序代码,如下:运行编译后,输出结果是()。
A.count1=9count2=9
B.count1=10count2=9
C.count1=10count2=10
D.count1=9count2=10
第20题:
● 下面C程序段中count++语句执行的次数为 (64) 。
for(int i = 1;i <= 11;i *= 2)
for(int j = 1; j <= i;j++)
count++;
(64)
A. 15
B. 16
C. 31
D. 32
第21题:
int [] my_Array; my_Array = new int[5]; for(int count = 0; count <= 5; count++) System.out.println(my_Array[count]); 结果是()
第22题:
编译如下Java程序片断: class test{ int count = 9; public void a(){ int count=10; System.out.println("count 1 =" + count); } public void count(){ System.out.println("count 2 =" + count); } public static void main(String args[]){ test t=new test(); t.a(); t.count(); } } 结果将()。
第23题:
将1,2,3,4,5输出到屏幕
将0,1,2,3,4输出到屏幕
将0,1,2,3,4,5输出到屏幕
将出现运行时异常
第24题:
不能通过编译
输出:count 1 =10 count 2=9
输出:count 1=9 count 2=9