网院作业 发表于 2019-12-3 17:46:32

[0837]《面向对象程序设计》西南大学2019年12月机考大作业


西南大学网络与继续教育学院课程考试试题卷类别:网教       专业:计算机科学与技术      
课程名称【编号】:面向对象程序设计【0837】             A卷
满分:100 分
一、单项选择题(共10小题,3分/题,共30分)
以下关于Java语言的叙述错误的是:(      )
Java 是最纯粹的面向对象语言,对面向对象方法学的支持也最全面
Java是解释执行的语言,由Java解释器负责将Java源文件解释为机器码执行
Java是平台无关的,即Java程序不用修改就可以在不同类型的计算机平台上运行
Java提供了大量功能丰富的可重用类库,有效减少了编程的工作量
下列字符序列中不能作为Java语言标识符的是:(      )
abc_123
圆周率PI
false
_123abc
下列不属于Java语言关键字的是:(      )
repeat
try
break
new
设有定义 int i=80, j=7; double d=80.7;下列语句中正确的赋值语句是:(      )
i = d;
i= (int)d + j;
j = (int)i - d;
i + j = (int)d;
下列关于构造方法的说法中,不正确的是:(      )
构造方法用于创建类的实例
构造方法不可以重载
构造方法不具有返回值类型
构造方法名必须和类名相同
执行下列语句后,变量x的值是:(      )
    int x=7, y=10;
   switch( x/y ) {
case 0: x++;
case 7: x*=y;
case 14:x+=y; break;
default: x%=y;
        }
8
70
80
90
下列语句序列给出了k,myArr和myMethod()的声明。当调用方法myMethod(myArr,k)之后,存储在k和myArr里的值分别是:(      )
int k = 7;
String myArr[] = {“love”,“peace”,”and”};
void myMethod(String a[], int m) {
   String temp = a;
   a = a;
   a = temp;
   m = a.length();
}
{“peace”,“love”,”and”},4
{“peace”,“love”,”and”},7
{“love”,“and”,”peace”},5
{“love”,“and”,”peace”},7
下列语句序列执行之后,b1,b2,b3,b4的值分别是:(      )
String s1 = “peace”;
String s2 = new String(s1);
String s3 = s2;
String s4 = new String(“PEACE”);boolean b1 = (s1 == s2);
boolean b2 = s1.equals(s2);
boolean b3 = (s3 == s2);
boolean b4 = s4.equals(s3);true,true,false,false
false,true,true,true
false,true,true,false
false,true,false,false
Swing的三个顶层容器分别是:(      )
JApplet,JPanel,JWindow
JDialog,JApplet,JFrame
JApplet,JFrame, JMenu
JFrame,JPanel,JTextArea
下列关于Java小应用程序(Applet)的说法中,正确的是:(      )
java.applet.Applet类是所有Java小应用程序的基类
Java小应用程序不需要编译
Java小应用程序也需要main()方法
Java小应用程序必须实现ActionListener接口
二、程序分析题(共4小题,每小题各10分,共40分)
阅读下面的程序,写出程序运行的输出结果。
public class Test1 {
        public int method(int n){
                int result = 1;
                for(int i=1; i<=n; i++){
                        result *= n;
                }
                return result;
        }
    publicstaticvoid   main( Stringargs[ ] ){
            Test1 test = new Test1( );
      int   sum = 0 ;
      for( inti = 1 ;i <= 3 ;i++ )
             sum += test.method( i ) ;
      System.out.println( "sum = " + sum );
}
}
      
阅读下面的程序,写出程序运行的输出结果。
public class Test2 {
        public String method( String s ) {
         StringBuffer result = new StringBuffer( );
         for (int k = s.length( )-1; k >= 0; k--) {
               result.append( s.charAt(k) );
         }
         return result.toString( );
       }
        public static void main( Stringargs[ ] ) {
                Test2 test = new Test2( );
String str = "peace";   
         System.out.println( test.method(str) );
        }
}阅读下面程序,并回答问题。
class SuperTest {
public int age ;
public SuperTest( String s ) {
        System.out.println("Hi, I am " + s);
       age = 35;
  }
}public class Test3 extends SuperTest{
public int age;
public Test3 ( String s ) {
          super( s );
          System.out.println("Nice to meet you!");
      age = 7;
}         public void print() {
      System.out.println( "Age is " + age );
      System.out.println( "My age is " + this.age );
      System.out.println( "My parent's age is " + super.age );       
        }public static void main( String args[ ] ){
          Test3 test = new Test3(“Olive”);
test.print();
}
}
问题(1):类Test3和类SuperTest之间是什么关系?
问题(2):关键字super和this分别是什么含义?
问题(3):这段程序的输出是什么?阅读下面程序,并回答问题。
importjava.io.* ;public class Test4{
        public static void main( String args[ ]){   
             try {
                   DataOutputStreamdout = new DataOutputStream(
newFileOutputStream(“out.txt”));
                        for(int i=0; i<10; i++)
                  dout.writeInt( ‘0’ + i);
                dout.close( );                DataInputStreamdin = new DataInputStream(
newFileInputStream(“out.txt”));
                        for(int i=0; i<10; i++)
                  System.out.print( din.readInt( )-‘0’ + ”, ” );
                din.close( );
                      } catch ( IOExceptione ){
                              System.err.println( “发生异常:”+e );
                  e.printStackTrace( );
                      }
    }
}问题(1):try块中包含的哪些语句或表达式可能抛出异常?
问题(2):流DataOutputStream和DataInputStream常被用于何种操作?
问题 (3):假定文件out.txt中原本没有任何数据,这段程序执行完成后,文件out.txt的内容是什么?程序在控制台窗口输出什么?
三、程序设计题(共1小题,共30分)
编写一个程序,要求随机生成61个学生的成绩(从0到100的整数),在将成绩排序(由高到低)后保存到文件“score.txt”中。附件是答案,核对题目下载,转载注明 www.ap5u.com
页: [1]
查看完整版本: [0837]《面向对象程序设计》西南大学2019年12月机考大作业