java期末考试题 联系客服

发布时间 : 星期六 文章java期末考试题更新完毕开始阅读a0ac9b05250c844769eae009581b6bd97e19bcf1

in.close();

out.close(); }

}

4、写出以下程序的功能。

class Test

{ public static void main(String[] args)

{ String s;

char c;

int upper,lower;

upper=lower=0;

s=args[0];

for (int i=0;i

{ c=s.charAt(i);

if(c>='a' && c<='z') lower++;

if(c>='A' && c<='Z') upper++; upper+”,”+lower); }

}

}

5、写出以下程序的运行结果。

import java.util.*;

public class Vec{

public static void main(String[] args) {

String[] s;

s=new String[2];

s[0]=new String(\

s[1]=new String(\

Vector v = new Vector();

for(int i = 0; i <2; i++) v.addElement(s[i]);

v.insertElementAt(new String(\

Enumeration e = v.elements();

v.removeElement(\

}

}

6、写出以下程序的运行结果。

class StaticTest {

static int x=1;

int y;

StaticTest()

{ y++; }

public static void main(String args[ ]){

StaticTest st=new StaticTest();

st=new StaticTest();

}

static { x++;}

}

7、阅读以下程序,写出输出结果。

class First{

public First(){

aMethod(); }

public void aMethod(){

“in First class”);}

}

public class Second extends First{

public Second(){

aMethod(); }

public void aMethod(){

“in Second class”);}

public static void main(String[ ] args){

new Second( ); }

}

8、写出以下程序的运行结果。

public class A

{

public static void main(String[ ] args)

{ test(15,26,4) ); }

static int test(int x, int y, int z)

{ return test( x, test(y,z) ); }

static int test(int x,int y)

{ if(x>y) return x;