首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

2010-2011 学年首先学期期末考试试题(A卷)

2012-12-26 
2010-2011学年第一学期期末考试试题(A卷)一、选择题(每题4分,共12分)1.指出下列程序运行的结果 (????? )pub

2010-2011 学年第一学期期末考试试题(A卷)

一、选择题(每题4分,共12分)

1.指出下列程序运行的结果 (????? )

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.str,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

?

2.给出下面代码:
  1) class Parent {
  2) private String name;
  3) public Parent(){}
  4) }
  5) public class Child extends Parent {
  6) private String department;
  7) public Child() {}
  8) public String getValue(){ return name; }
  9) public static void main(String arg[]) {
  10) Parent p = new Parent();
  11) }
  12) }
  那些行将引起错误? (?? )
A、 第3行 ???B、 第6行 ????C、 第7行 ??????D、 第8行

3.对于下列代码:
  1) class Person {
  2) public void printValue(int i, int j) {//... }
  3) public void printValue(int i){//... }
  4) }
  5) public class Teacher extends Person {
  6) public void printValue() {//... }
  7) public void printValue(int i) {//...}
  8) public static void main(String args[]){
  9) Person t = new Teacher();
  10) t.printValue(10);
  11) }
  第10行语句将调用哪行语句? (?? )

A、 line 2 ???B、 line 3 ???C、 line 6 ?????D、 line 7

?

二、阅读程序(每题5分,共20分)

1.请写出下面程序的运行结果。
  public class Test extends TT{

??? public static void main(String args[]){

?????? Test t = new Test("Tom");

??? }

??? public Test(String s){

?????? super(s);

?????? System.out.print(" How do you do?");

??? }

??? public Test(){

?????? this("I am Tom.");

??? }

}

class TT{

??? public TT(){

?????? System.out.print("What a pleasure!");

??? }

??? public TT(String s){

?????? this();

?????? System.out.print("I am "+s);

??? }

}

结果: _________________________________________

?

2.以下程序的输出结果为________________________________________。

class Course{

??? private String cNumber;

??? private String cName;

??? private int cUnit;??

??? public Course(String number,String name,int unit){

?????? cNumber=number;cName=name;cUnit=unit;?

??? }

??? public void printCourseInfo(){

?????? System.out.println ("课程号:"+cNumber+" 课程名:"+cName+" 学分:"+cUnit);

??? }

}

public class CourseTest{

??? public static void main(String[]args){

?????? Course c;

?????? c=new Course("101","JAVA",3);

?????? c.printCourseInfo();

??? }

}

3.以下程序的输出结果为______________________________。

public class Person{

??? String name;

??? int age;

??? public Person(String name,int age){

?????? this.name=name;

?????? this.age=age;

??? }

??? public static void main(String[]args){

?????? Person c=new Person("Peter",17);

?????? System.out.println(c.name+" is "+c.age+" years old!");

??? }

}

?

4.以下程序的输出结果为________________________________。

public class Computer{

??? String mainbord,cpu;

??? public Computer(String s1,String s2){

?????? mainbord=s1;

?????? cpu=s2;??? }

??? public static void main(String[]args){

?????? Computer c=new Computer("华硕","Intel");

?????? System.out.println("mainbord:"+c.mainbord+" cpu:"+c.cpu);

??? } }

?


?


?

?

热点排行