更多"阅读以下程序,请写出输出结果_________ public cla"的相关试题:
[简答题]阅读下列程序,请写出该程序的输出结果。
public class C
int x=10;
static int y=20;
public static void main(String[] args)
C obj1=new C( );
C obj2=new C( );
obj1.x*=2;
obj1.y*=3;
obj2.x+=4;
obj2.y+=5;
System. out. println(obj1.x);
System. out. println(obj1.y);
System. out. println(obj2.x);
System. out. println(obj2.y);
[简答题]
阅读下列程序,请写出该程序的输出结果。
class Test33 {
static int merger(int [] a, int []b, int []c){
int i = 0, j = 0, k = 0;
while(i < a.length && j < b.length) {
if(a[i] < b[j])c[k++] = a[i++];
else c[k++] = b[j++];
}
while(i < a.length) c[k++] = a[i++];
while(j < b.length) c[k++] = b[j++];
return k;
}
public static void main(String[] args) {
int a[] = {3, 6, 9};
int b[] = { 1, 2, 5};
int []c = new int[100];
int p = merger(a, b, c);
for(int k = 0; k < p; k++)
System.out.print(c[k]+ (k < p-1 " ":"/n"));
}
[简答题]
阅读下列程序,请写出该程序的输出结果。
public class A {
int m = 5;
static int n = 3;
public static void main(String[] args) {
A obj 1 = new A( );
A obj2 = new A( );
objl.m *= 2;
objl.n *= 4;
obj2.m += 1;
obj2.n += 6;
System.out.println("obj 1.m=’’ + obj 1.m);
System.out.println("obj 1.n=" + obj 1.n);
System.out.println("obj2.m=" + obj2.m);
System.out.println("obj2.n=" + obj2.n);
}
}
[填空题]阅读以下程序,请写出输出结果_________
public class EqualsMethod{
public static void main (String[]args){
Integer nl=new Integer (47):
Integer n2=new Integer (47);
System.out.println(n1.equals(n2));
}
[简答题]阅读以下程序代码,写出程序的输出结果。
public class Class33
public static void main(String[] args)
int a,b,c;
a=b=c=1;
boolean w;
w=a++>1&&++b>c++:
System. out. println(a+","+b+","+c+","+w);
[简答题]阅读以下程序代码,写出程序的输出结果。
public class Class35
public static void main(String[] args)
String s1=new String("0860371"),s2="0860371";
System. out. println(s1==s2);
System. out. println(s1. equals(s2));
System. out. println(s1. endsWith(s2)==s1. startsWith(s2));
[简答题]阅读以下程序代码,写出程序的输出结果。
public class Class32
public static void main(String[] args)
boolean x=true,y=false,z=false;
x=x&&y||z;
y=x||y&&z;
z=!(x!=y)||(y==z);
System. out. println(x+","+y+","+z);
[填空题]若程序中已给整型变量a和b赋值10和20,请写出按以下格式输出a、b值的语句 【6】 。
****a=10,b=20****
[简答题]
阅读下列程序,请写出该程序的功能。
import java util.*;
class MyThread extends Thread {
int pauseTime; String name;
public MyThread (int x, String n) { pauseTime = x; name = n; }
public void run( ) {
for(int i = 1;i <= 4; i++) {
try {
System.out.println(name +":" +new Date(System.currentTimeMillis( )));
Thread.sleep(pauseTime);
}catch(Exception e){ }
}
}
}
public class Test36{
static public void main(String[] args) {
MyThread thread1 = new MyThread (1000,"Fast Thread"); thread 1 .start( );
MyThread thread2 = new MyThread (3000,"Slow Thread"); thread2.start( );
}
}
[简答题]阅读下列程序,请写出程序的运行结果。
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");
[填空题]以下程序输出100以内的所有质数。
public class Class29
public static void main(String[] args)
int i,j,k=0;
System. out. println("100以内的质数有:");
for(i=3;i<=100;i++)
for(j=2;j<=i/2;j++)
if(i%j==0)______;
if______
System. out. print(i+" ");
k++;
if(k%8==0) System. out. println( );
System. out. println("共"+k+"个。");
[填空题]阅读以下程序,输出结果为_________。
class D{
public static void main (String args[]){
int d=21;
Dec dec=new Dec( );
dec. decrement (d):
System.out.println(d);
}
}
class Dec{
public void decrement(int decMe){
decMe=decMe-1:
}
}
[填空题]阅读以下程序,输出结果为_________。 class D public static void main (String args[]) int d=21; Dec dec=new Dec( ); dec. decrement (d): System.out.println(d); class Dec public void decrement(int decMe) decMe=decMe-1:
[填空题]以下程序输出1~100之内的奇数和、偶数和。
public class class28
void sum(int n)
int s1,s2,i=0;
______
while(i<n)
i++;
if(i%2==1)
s1+=i;
______
s2+=i:
System. out. println("奇数和:"+s1+"/n偶数和:"+s2);
public static void main(String[] args)
(new class28( )).sum(100);
[单项选择]以下程序输出结果为( )。
class test 2
public static void main(String args[])
int n=7;
n<<=3;
n=n&n+1 |n+2^n+3;
n>>=2;
System.out.println(n);
A. 0
B. -1
C. 14
D. 64
[单项选择]以下程序输出结果为( )。
class test 2
public static void main(String args[])
int n = 7;
n<<=3;
n=n&n+1|1n+2^n+3;
n>>=2;
System.out.println(n);
A. 0
B. -1
C. 14
D. 64
[简答题]阅读以下程序代码,写出程序的功能。
public class Class34
public static void main(String[] args)
int a=1,b;
while(a<=9)
b=1;
while(b<=a)
System. out. print(" "+a+"×"+b+"="+a*b);
b++;
System. out. println( );
a++;
[填空题]以下程序的输出结果是:true,234。
public class Class31
public static void main(String[] args)
String s1=new String("abc");
String s2=new String("Abc");
boolean b;
b=s1.______;//忽略大小写,比较字符串s1,s2是否相等
s1=new String("0123456789");
s2=s1.______;
System. out. println(b+","+s2);
[填空题]请写出下面程序的运行结果:
public class Test extends TT{
public static void main(String args[])(
Test t=new Test("Tom.");
}
public Test(SUing s){
super(s);
System.out.print("How are you");
}
public Test( ){
this("I am Jack.");
}
}
class TT{
public TT( ) {
System,out.print("Hi!");
}
public TT(String s){
this( );
System.out.print("I am"+s);
}
}
结果: 【15】 。