离线作业答案 发表于 2020-12-3 12:37:17

西南大学20年12月[0837]面向对象程序设计大作业答案

西南大学培训与继续教育学院课程考试试题卷学期:2020年秋季                                       
课程名称【编号】:面向对象程序设计【0837】                  A卷
考试类别:大作业                                     满分:100分

一、单项选择题(共10小题,3分/题,共30分)
Java语言具有许多优点和特点,下列选项中,哪个反映了Java程序“一次编写,到处运行”的特点:(      )
多线程
与平台无关
面向对象
分布式
下列字符序列中可以作为Java语言标识符的是:(      )
true
123_xyz
x.y
_x123
下列选项中,用于声明实现一个接口关键字是:(      )
interface
implements
import
abstract
设有定义 int i=7;char ch='b'; 下面赋值语句中不正确是:(      )
i = ch;
ch = i;
ch = (char)i;
i = (int)ch;
以下由for 语句构成的循环的执行次数是:(      )
    for ( int i = 0; i<=0; i = i ) ;
有语法错,不能执行
一次也不执行
执行1次
无限次
既能作为类的修饰符, 也能作为类成员的修饰符的是(    )
public
extends
void
private
下列构造String的语句中,不正确的是:(      )
String str2 = “” ;
String str1 = new String( );
String str4 = “” + 123;
String str3 = new String(123);
下列语句序列给出了myArr,k与myMethod()的声明。当调用方法myMethod(myArr,k)之后,存储在myArr和k里的值分别是:(      )
String myArr[] = {“peace”,“love”,“and”};
int k = 7;
void myMethod(String a[], int m) {
   String temp = a;
   a = a;
   a = temp;
   m = a.length();
}
{“peace”,“love”,”and”},7
{“peace”,“love”,”and”},4
{“peace”,“and”,”love”},7
{“peace”,“and”,”love”},4
把容器划分为东、西、南、北、中5个区域的布局管理器是:(      )
BoxLayout
FlowLayout
CardLayout
BorderLayout
从开始执行到执行结束,小应用程序经历的3个状态分别是:(      )
初始态、就绪态,结束态
就绪态、运行态,停止态
初始态、运行态,停止态
就绪态、运行态,休眠态二、程序分析题(共4小题,每小题各10分,共40分)
阅读下面的程序,写出程序运行的输出结果。
public class Test1 {
        public int method(int n) {
                int result = 1;
                for(int i=1; i<=n; i++) {
                        result *= i;
                }
                return result;
        }
    public static void main( String[] args) {
            Test1 test = new Test1( );
      intsum[ ] = new int;
      for ( int i=1; i <=5; i++) {
             sum = test.method(i) ;
             System.out.print(sum + " ");
}
}
        }阅读下面的程序,写出程序运行的输出结果。
public class Test2 {
        public static char method(char ch){
                if((ch>='A') && (ch<='Z'))
                        return (char)(ch + 32);
                else return ch;
        }
        public static void main(String[] args) {
                String s= "0123456789ABCDEF",s1="";   
          for (int i=s.length()-1; i>=0; i--)
                  s1 = s1 + method(s.charAt(i));
      System.out.println(s1);
        }
}阅读下面程序,并回答问题。
class Parent {
        public void printMe( ) {
                System.out.println("parent");
        }
}class Child extends Parent {
        public void printMe( ) {
                System.out.println("child");
        }
        public void printAll( ) {
         super.printMe( );
         this.printMe( );;
    }
}public class Test3 {
        public static void main(String[] args) {
                Child myC = new Child( );
                myC.printAll( );
        }
}问题(1):类Child和类Parent之间是什么关系?
问题(2):关键字super和this分别是什么含义?
问题(3):这段程序的输出是什么?阅读下面程序,并回答问题。
import javax.swing.*;
import java.awt.*;                           
import java.awt.event.*;public class Test4 extends JApplet implements ActionListener{
        private Container cp = getContentPane();;
        private JLabel prompt = new JLabel("请点击按钮");      
        private JButtonstart = new JButton("开始");
        private JTextField output = new JTextField(20);
        public void init( ){
                cp.setLayout(new FlowLayout());
                cp.add(start);
                cp.add(prompt);
                cp.add(output);
                output.setEditable(false);
               start.addActionListener(this);
    }
        public void actionPerformed(ActionEvent e){
                if ((JButton)e.getSource( ) == start )
                        output.setText("好好学习,天天向上");
    }
}
问题(1):Java程序分为哪两种类型,这段程序是哪一类Java程序?
问题(2):这个图形用户界面上包含那几类组件?点击按钮后程序显示什么?
问题(3):ActionListener是什么?程序中哪个方法是ActionListener中的方法?其功能是什么?三、程序设计题(共1小题,共30分)
编写一个简单的乘法器,界面如下图所示,在第一个文本框中输入第一个乘数;在第二个文本框中输入第二个乘数;当单击“=”按钮时,在第三个文本框中输出其乘积。
无忧答案网,附件是答案,核对题目后下载QQ 761296021
页: [1]
查看完整版本: 西南大学20年12月[0837]面向对象程序设计大作业答案