更多"指出下列程序运行的结果 ( ) public class Exa"的相关试题:
[单项选择]指出下列程序运行的结果 ( ) public class Example{ String str=new String("good"); char[]ch={’a’,’b’,’c’}; public static void main(String args[]){ Example ex=new Example( ); ex.change(ex.otr,ex.ch); System.out.print(ex.str+"and"); System.out.print(ex.ch); } public void change(String str,char ch[])} str="test ok"; ch[0]≈’g’; } }
A. good and abc
B. good and gbc
C. test ok and abc
D. test ok and gbc
[单项选择]下列程序的运行结果是() public class test{ private String[] data={“10”,“10.5”}; public void fun(){ double s=0; for(int i=0;i<3;i++){ try{ s=s+Integer .parseInt(data[i]); }catch(Exception e){ System.out.print(“errorl:”+data[i]); } } } public static void main(String[]args){ try{ testd=new test(); d .fun(); }catch(Exception e){ System.out.printIn(“error2”); } } }
A. errorl:10.5
B. error2
C. errorl:10.5 error2
D. 以上都不对
[简答题]阅读下列程序,写出程序运行结果。
public class C3302
public static void main(String[] args)
int[][]a=1,2,3,4,5,6;
System.out.println(a.length+","+a[0].length+","+a[1][1]);
f3302(s[0],s[1]);
System. out. println(s[0]+","+s[1]);
String s1="abc",s2="123";
s1+="xyz";
s2. concat("xyz");
System. out. println(s1+","+s2);
static void f3302(String x,String y)
String z=x;x=y;y=z;
[简答题]阅读下列程序,写出程序运行结果。
class A1
public void f(int aa,int bb)
System.out.println(aa+bb);
class A2 extends A1
public void f(int aa,int bb)
System. out. println(aa-bb);
public class C3201 extends A2
public void f(int aa,int bb)
System. out. println(aa*bb);
public static void main(String[] args)
A1 a=new Al( );
A1 a1=new A2( );
A2 a2=new C3201( );
a.f(20,10);
a1.f(20,10);
a2.f(20,10);
[简答题]阅读下列程序,写出程序运行结果。
class A
int x,y;
A(int x,int yy) x=xx;y=yy;
interface A3202int f3202(A a);
interface B3202int g3202( );
public class C3202 extends A;implements A3202,B3202
A a=new A(x,y);
C3202(int x,int y)
super(x,y);
this. x=x*x;
this. y=y*y;
public int f3202(A a) return x*a.x+x*a.y;
public int g3202( )return x*a.x+x*a.y;
public static void main(String[] args)
int x=10,y=20;
A a=new C3202(x,y);
C3202 c=new C3202(x,y);
System. out. println(a.x+","+a. y);
System. out. println(c.f3202(a));
System. out. println(c. g3202 ( ));
[单项选择]下面程序运行后,输出结果为( )
public class Class07
Class07( )
System. out. println("0param");
Class07(int n)
System. out. println(n+"param");
public static void main(String[] args)
Class07 x=new Class07(100);
A. 出错
B. 0param
C. 100param
D. 程序不错,但没有信息输出
[填空题]如下两个源程序文件,分别编译后,运行Example.class文件,运行结果为______。
AB.java文件代码如下;
package test;
public class AB
{
int a=60;
public void show( )
{
System.out.println(”a=”+a);
}
Example.java文件代码如下:
import test.AB;
class Example
{
public static void main(String args[])
{
AB obj=new AB( );
obj.show( );
}
}
[填空题]以下程序的运行结果是【 】
#include <string.h>
typedef struct student{
char name[10];
long sno;
float score; }STU;
main( )
{ STU a={“zhangsan”,2001,95},b={“Shangxian”,2002,90},
c={“Anhua”,2003,95},d,*p=&d;
d=a;
if(strcmp(a.name,b.name)>0) d=b;
if(strcmp(c.name,d.name)>0) d=c;
printf(“%ld%s/n”,d.sno,p->name); }
[填空题]
以下程序的运行结果是 【19】
#include <string.h>
typedef struct student{
char name[10];
long sno;
float score; }STU;
main( )
{ STU a={“zhangsan”,2001,95},b={“Shangxian”,2002,90},
c={“Anhua”,2003,95},d,*p=&d;
d=a;
if(strcmp(a.name,b.name)>0) d=b;
if(strcmp(c.name,d.name)>0) d=c;
printf(“%ld%s/n”,d.sno,p->name);
[单项选择]下面程序的运行结果是( )。 public class OperatorsAndExpressions{ void equalsMethod1( ){ //基本类型的数据之间的比较 int i=10,j=15; System.out,println(i==j); //复合数据类型的数据之间的比较 String s1=new String ("how are you"); String s2=new String ("how are you"); System.out.println(s1==s2): } public static void main (String args[ ]){ OperatorsAndExpressions OperAndExp=new OperatorsAndExpressions( ): //用于基本类型数据和复合类型数据的=="运算符 OperAndExp,equalsMethod1( ) } }
A. false false
B. false true
C. tree false
D. true true
[简答题]阅读下列程序,请写出程序的运行结果。
public class C
public static void main(String[] args)
String text="public static void main(String[] args)";
int theCount=0;
int index=-1;
String theStr="i";
index=text. indexOf(theStr);
while(index>=0)
++theCount;
index+=theStr. length( );
index=text. indexOf(theStr,index);
System. out. println("The Text contains"+theCount+"i");