华南理工大学java模拟题 (5)
- 格式:doc
- 大小:112.50 KB
- 文档页数:16
最新JAVA编程题全集_50题及答案写一个函数,例如:给你的 a b c 则输出 abc acb bac bca cab cba import java.util.ArrayList; import java.util.List;public class NumT est {public static void main(String[] args) {String s="ABCD"; //原字符串List res ult = list(s, "");//列出字符的组合,放入resultSystem.out.printl n(result.size());;System.out.printl n(result);}/*** 列出基础字符串(base)的所有组合* @param base 以该字符串作为基础字符串,进行选择性组合。
* @param buff 所求字符串的临时结果* @param result 存放所求结果*/public static List list(String base,String buf f){List res ult = new ArrayList();/ /存放结果信息。
if(base.length()< =0){result.ad d(buff);}for(int i=0;i<="">List temp = list(new StringBuilder(base).deleteCharAt(i).toString (),buff+base.charAt(i));result.ad dAll(temp);}return result;}}+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++ public static void main(String [] args) {String s="ABCD";//原字符串List result = new ArrayList();//存放结果信息。
《Java语言程序设计》模拟试题(一)一、单选题(1分/题,共20题)1.以下语句中,共有错误____处public class Hello{public static void main(String[] args){//错误1:类方法没有static标识System.out.println(‘Welcome to Java’);//错误2::双引号而非单引号}}A. 1处B. 2处C. 3处D. 4处2.下列关于类方法、实例方法、类变量、实例变量的说法中,正确的是A. 类方法可以调用类方法B. 类方法不能访问类变量C. 类方法可以调用实例方法D. 实例方法可以访问类变量3.导致程序运行时出现NoClassDefoundError错误的原因可能是A. javap.exe不存在B. 被访问的类中没有main方法C. 运行程序的命令行中没传递参数D. 环境变量设置错误4.关于以下两个Java语句的说法中,正确的是语句①:import java.util.Scanner;语句②:import java.util.*;A. 语句②可以导入Scanner类B. 语句①和语句②的作用相同C. 语句①比语句②导入的类更多D. 语句①导入Scanner类及其子类5.Java中所有类的基类是A. Class类B. Object类C. Thread类D. System类6.在Java语言中,能实现多重继承的方式是A. 抽象类B. 匿名类C. 接口D. 泛型类7.下列表达式的值为true的是A. 3>3B. a<5C. ‘a’==‘a’D. x!=‘x’8.要得到某个文件夹下的所有文件名,下列代码应该填写File dir = new File(args[0]);String[] filename = dir.__________();A. mkdir()B. listC. listFilesD. getName9.下列不能作为类成员的访问控制符的是A. staticB. protectedC. publicD. private10.下列关于构造方法的说法中正确的是A. 子类可以调用父类的构造方法B. 构造方法不能重载C. 构造方法返回类型为intD. 构造方法是一种实例方法11.为了区分重载方法,Java语言要求A. 使用不同的访问权限B. 使用不同的参数名C. 采用不同的形参列表D. 返回的数据类型必须不同12.Java多线程程序中,通过集成Thread类的方式创建线程,则需要重写的方法是A. run()B. sleep()C. start()D. Thread()13.以下Java类定义的横线上应为___________ class Example{private int parametera, parameterb;public abstract double compute(int parametera, int parameter);}A. publicB. privateC. abstractD. final14.已知MySQL数据库message中的表courses的字段为ID、Title、Content、SubmissionTime. 要仅列出courses中Title为“关于期末考试的建议”的记录中字段Title、Content和SubmissionTime,应执行SQL语句A. select ID, Title from coursesB. select * from coursesC. select * from courses whrer Title=”关于期末考试的建议”D. select Title, Content, SubmissionTime from courses where Title=”关于期末考试的建议”15.所有异常类的父类是A. ng.ThrowableB. ng.ErrorC. ng.ThreadD. java.io.Exception16.类Circle实现了接口Compute,则一下语句中正确的是A. Compute compute = new Compute();B. Compute Circle();C. Circle circle = new Compute();D. Compute compute = new Circle();17.以下关于泛型的说法中,正确的是A. 泛型类中可以有多个泛型B. 泛型不能用于接口C. 泛型类实例化对象时不必指明泛型的具体类型D. 泛型可以是基本数据类型18.Java语言中,启动线程的方法是A. start()B. run()C. wait()D. sleep()19.下列Java程序的执行结果是class Example{public static void main(String[] args){int a[]={1,2,3,4,5,6,7,8,9};for(int i=0;i<a.length;i++)System.out.print(a[i]+a[a.length-1]+” ”);System.out.println();}}A. 10 10 10 10 10B. 10C. 1 2 3 4 5 6 7 8 9D. 4520.以下Java程序的执行结果是class Example implements B{public static void main(String[] args){int I;Example example = new Example();I=example.k;System.out.println(i);}}interface B{int k=10;}A. 10B. falseC. 0D. true二、填空题(每空1分,共10分)1.在Java语言中,加号“+”的两种作用是:算术运算符和连接符。
Java程序设计B试卷参考答案与评分标准1、(20’)Write a program prints out all leap year from 2000 to 2050.参考答案:public class Leap { -----3分public static void main(String[] args) { -----4分for(int year=2000;year<=2050;year++) -----4分{if((year%4==0&&year%100!=0)||year%400==0) -----6分System.out.println(year); -----3分}}}2、(20’)Write an application with a button whose caption is “green” anda panel in the center of the frame, if you click the button, the background color of the panel will be changed to greenRemind(提示):void actionPerformed(ActionEvent e)参考答案:import java.awt.BorderLayout;import java.awt.Color;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JPanel;class myFrame extends JFrame{JButton button;JPanel panel;final int WIDTH=400;final int HEIGHT=400;int i=0;class myListener implements ActionListener-----2分{@Overridepublic void actionPerformed(ActionEvent e) {-----6分// TODO Auto-generated method stubpanel.setBackground(Color.green);}}public myFrame(){button=new JButton("green");ActionListener clickListener=new myListener();-----2分button.addActionListener(clickListener); -----2分panel=new JPanel();JPanel panel1=new JPanel();-----2分panel1.setLayout(new BorderLayout());panel1.add(button, BorderLayout.NORTH);panel1.add(panel, BorderLayout.CENTER); -----2分add(panel1);setSize(WIDTH,HEIGHT); -----2分setVisible(true);}public static void main(String[] args) {-----3分JFrame frame=new myFrame();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}}3、(20’)Write a program that reads text from a file whose name is d:\demon.txt and breaks it up into individual words. Insert the words into a hash set. At the end of the program, print all words, followed by the size of the resulting set. This program determines how many unique words a text file has.参考答案:import java.io.File;import java.util.HashSet;import java.util.Scanner;import java.util.TreeSet;public class CountWords{public static void main(String[] args){try{File file = new File("d:/demon.txt "); ----4分Scanner in = new Scanner(file);HashSet<String> uniqueWords = new HashSet<String>();while (in.hasNext())----8分{String word = in.next();uniqueWords.add(word);}for (String word : uniqueWords) ----5分{System.out.println(word);}System.out.println("Total unique words: " + uniqueWords.size()); }catch( Exception e ) ----3分{System.err.println("Invalid Filename: " + e.getMessage());}}}4、(20’)Implement a superclass Person. Make a classes, Instructor, that inherit from Person. A person has a name and a year of birth. An instructor has a salary. Write the class declarations, the constructors using fields, and the methods toString for all classes. Supply a test program that tests these classes and methods.A test program that tests these classes and methods like this:public class Test{public static void main(String[] args) {Person p1 = new Person("Larry", 1950);Person p2 = new Instructor("Sally", 1970, 40000);System.out.println(p1);System.out.println(p2);}}The result of this program is like this:参考答案:public class Person {private String name; -----2分private int yearOfBirth;public Person(String name, int yearOfBirth) -----5分{ = name;this.yearOfBirth = yearOfBirth;}public String toString()-----3分{return name + " " + yearOfBirth;}}public class Instructor extends Person {private int salary; ----2分public Instructor(String name, int yearOfBirth, int salary) -----5分 {super(name, yearOfBirth);this.salary = salary;}public String toString() -----3分{return super.toString() + " " + salary;}}5、(20’)Write a program that uses RandomAccessFile writes the following keys and values to a Dat file, read the double value whose key is i(1<=i<=4), and read all values.1 123.4562 234.5673 345.6784 456.789”Remind:readDouble() method can read a double value.writeDouble() method can write a double value.参考答案:import java.io.File;import java.util.Scanner; -----file header 2分public class RandomValues{public static void main(String[] args){ -----main method 5分Scanner reader= new Scanner(System.in); -----variable definition 3分System.out.println("请输入dat文件名:");String name=reader.next();key=3;File f=new File(name);if (f.exists()){System.out.println("文件已存在");return;}if (f.isDirectory()){System.out.println("这是一个目录");return;}try{write(f,1,123.456);write(f,2,234.567);write(f,3,345.678);write(f,4,456.789);read(f,key);readall(f);}catch(IOException e){throw new BadInputException("RandomAccessFile 错误");}}public static void read(File f,int key) throws IOException{ -----read method 5分RandomAccessFile ra=new RandomAccessFile(f,"r");ra.seek(key*(4+8));double dvalue=ra.readDouble();System.out.println(dvalue);ra.close();}public static void readall(File f) throws IOException{RandomAccessFile ra=new RandomAccessFile(f,"r");long sum=ra.length();while(ra.getFilePointer()<=sum){System.out.println(ra.readInt());System.out.println(ra.readDouble());}ra.close();}public static void write(File f,int key, double dvalue) throws IOException{-----write method 5分RandomAccessFile ra=new RandomAccessFile(f,"rw");ra.seek(key*(4+8));ra.writeInt(key);ra.writeDouble(dvalue);ra.close();}}。
1 1.下面是关于for 语句简化写法的程序,请完善程序。 import java.util.Iterator; import java.util.Vector; public class J_VectorFor { public static void main(String args[ ]) { Vector a = new Vector( ); a.add( "a" ); a.add( "b" ); a.add( "c" ); for ( String c : a) System.out.print(c + ", "); System.out.println( ); for ( Iterator i=a.iterator( ); _____①i.hasNext()__; ) { String c = ___②i.next()__; System.out.print(c + ", "); } System.out.println( ); } } 五、读程序写结果 1.写出下列程序在控制台窗口中的输出结果。 public class J_Intern { public static void main(String args[ ]) { String s1 = "123456"; String s2 = "123456"; String s3 = "123" + "456"; String a0 = "123"; String s4 = a0 + "456"; String s5 = new String("123456"); System.out.println("s2" + ((s2==s1) ? "==" : "!=") +"s1"); 第 3 页 共 3 页 System.out.println("s3" + ((s3==s1) ? "==" : "!=") +"s1"); System.out.println("s4" + ((s4==s1) ? "==" : "!=") +"s1"); System.out.println("s5" + ((s5==s1) ? "==" : "!=") +"s1"); } } 程序运行结果是:.s2==s1 s3==s1 s4!=s1 s5!=s1 六、编程题 1 .编写程序求出给定的一个整型数组 a 中的和值。其中 a={10,9,5,3,2,6,7,62,73,12,181}。
华南农业大学Java程序设计期末考试参考答案(A卷)————————————————————————————————作者:————————————————————————————————日期:华南农业大学期末考试参考答案(A卷)2012-2013学年第1 学期考试科目:Java程序设计考试类型:(闭卷)考试考试时间:120 分钟一、单项选择题(本大题共18 小题,每小题 2 分,共36 分)1 2 3 4 5 6 7 8 9B DC BD C D A A10 11 12 13 14 15 16 17 18B C D C B C A B A二、判断题(本大题共14小题,每小题1分,共14分,正确选A,错误选B)1.5CM19 20 21 22 23 24 25B A A B A B A26 27 28 29 30 31 32B A B B A B A三、程序阅读题(本大题共4小题,每小题5分,共20分)评分细则:1-2题错误没有分,3-4题每答错一行扣一分1.m=89,n=52.43.Person()Teacher(String)Teacher()Faculty()4.Woof woofMiiaoowwMiaomiao装订线四、编写程序题(本大题共3小题,共30分)1.(9分)public class Test { +1 public static void main(String[] args) { +1 int s = 0;for(int i=2;i<=10;i++){if(isPrime(i))s+=i;} +3 System.out.println("2~200间所有素数之和为:"+s); +1 }static boolean isPrime(int a){boolean b = true;for(int i=2;i<a;i++)if(a%i == 0){b = false; break;}return b;} +3 }2. (10分)public class Test { +1 public static void main(String[] args) {int[][] a = {{259,132,799,113},{332,262,209,863},{227,301,684,343}}; +1 int max = 0,r=0,c=0; +1for(int i=0;i<3;i++)for(int j=0;j<4;j++){int t = dsum(a[i][j]); if(max<t){max = t;r = i;c = j;}} +3 System.out.printf("数字和最大的数是:%d,位于数表的第%d行第%d列\n",a[r][c],r,c);} +1 static int dsum(int m){int s = 0;while(m!=0){s+=m%10; m=m/10;}return s;} +3 }1.5CM装订线3. (11分)class Employee { +0.5 private int id;private String name;private double salary; +1.5 Employee(){id = 0; name = ""; salary = 0.0;} +1 Employee(int id,String name,double salary){this.id = id; = name; this.salary = salary;} +1 public double getId(){return id;}public String getName(){return name;}public double getSalary(){return salary;} +1.5 public void setId(int id){this.id = id;}public void setName(String name){ = name;}public void setSalary(double salary){this.salary = salary;} +1.5 public String toString(){return "工号:" + id + ",姓名:" + name +",工资:" + salary;} +1 public int level(){int l;if(salary<5000.0) l = 3;else if(salary>=5000.0 && salary<8000.0) l = 2;else l = 1;return l;} +3}。
2010研究生华南理工大学《软件需求分析、设计与建模》试卷A一、单项选择题(本大题共15题,每题2分,共30分)注:所有的选项中,只有一个答案最符合题目要求,多选、错选均不得分,请将所选的答案依照题号对应填入下表。
1. Which kind of diagram in UML can be applied to describe external system events that are recognized and handled by system operators in the context of a use case ?A. Statechart Diagram. BB. Activity Diagram.C. Sequence Diagram.D.Collaboration Diagram.2. Why do we model? DA. Helps to visualize a system.B. Gives us a template for constructing a system.C. Documents our decisions.D. All of the above.3. What phrase best represents a composition relationship(组成关系)? AA. Is a part of.B. Is a kind of.C. Is an only part of.D. Is an inheritance of.4. Which of the following is good practice to use while designing for reuse? FA. Define a persistence framework that provides services for persisting objects(持久对象).B. Use design patterns, wherein(其中)complete solutions are already defined.C. Use controller objects to control the flow of processes in the system.D. Assign responsibilities to classes such that coupling between them remains high.E. A and B.F. A, B and C.G. A, B,C and D.5. Which of the following statement is Not TRUE? DA. A subsystem is a package that has separate specification and realization parts.B. A subsystem is a discrete entity that has behavior and interfaces.C. A subsystem can be identified by the stereotype <<subsystem>>.D. A subsystem is a package that has specification part only.6. In an OO system, it is NOT desirable(可取)to assign responsibilities: FA. relatively evenly across the classes.B. more heavily in a few controlling classes.C. according to interaction diagram(顺序图和协作图)messaging.D. according to the use case diagram.E.A and BF.B, C and D7. For showing how several objects collaborate in single use case, which one of the following OOAD artifacts(构件)is the MOST useful? AA. Interaction Diagrams(交互图:包括时序图和协作图)B. Activity DiagramsC. State DiagramsD. Class Diagrams8. What methods MUST be implemented by the Credit Processor class in the payment sequence diagram? CA. checkCredit, generateConfirmationCode, displayCofirmation.B. checkCredit, generateConfirmationCode.C. checkCredit, generateConfirmationCode, reserveSeat.D. checkCredit, reserveSeat, displayCofirmation.9. Which of the following is TRUE about a deployment diagram? BA. Since there is always some kind of response to a message, the dependencies are two-way between deployment components.B. Dependencies between deployment components tend to be the same as the package dependencies.C. Deployment diagrams are NOT to be used to show physical modules of code.D. Deployment diagrams do NOT show physical distribution of a system across computers.10. When using OOAD artifacts to organize and assign team responsibilities ona project, it is BEST to: CA. evenly distribute use cases among team members and have them work as independently as possible in order to minimize code dependencies.B. designate(指派)one team for implementing interaction diagrams related to the "common code path" and another team for implementing interaction diagramsrelated to "code path variations" (for example , conditional or error paths(条件或者错误路径)).C. divide teams according to the layers in the software architecture and have them work as independently as possible in order to minimize dependencies between the layers.D. divide teams according to package diagram dependencies and utilize use cases to schedule the work for the individual team members.11. To MOST effectively manage teams working on different packages within a large project, which one of the following should be TRUE? AA. One technical leader should control the project details and communicate decisions to the different teams.B. The team leaders should focus on which type of database ( DB2 UDB, Oracle, Sybase, or Instant DB ) is used.C. The team leaders should focus on quality designs for the internals of their packages, mentoring their team members.D. Communications between the teams should be minimized to reduce overhead burdens while they work on separate, independent use cases for their packages.12. Use cases CANNOT be used for : AA. modeling the non behavioral aspects such as data requirements, performance and security.B. capturing behavioral aspect of a system.C. capturing functional aspect of a system.D. capturing the business process at high level.13. What kind of association between the 2 classes described in java below? Bpublic class A{private ArrayList _Bs=new ArrayList();public A(_Bs:B){this._Bs.add(_Bs);}}public class B{…;}A.Inheritance B. DependencyC.Composition D. Aggregation14. Referring to the diagram below, which of the following is TRUE? BA.Class "Teacher" is a parent class of class "Professor" and class "Lecturer" .B.Instance of "Professor" has to realized all of the behavior s of "Teacher".C.There are instances of "Teacher" in the system.D."Professor" is a kind of "Teacher" and so does the "Lecturer".15. During the process of requirement engineering, the software engineer and the user of the system should work together to define EA. visible context of using the system for the userB.crucial software propertiesC.input and output of the systemD. A and BE. A, B and C二、填空题(共10分)1. A is a(n) 角色.2. B is a(n) 边界object.3. “1.1.3”is a(n) _______自调用_____ message4. “1.1”is a(n) ________调用_______ message.5. The dotted line below the boxes is called the _______对象生命线_____________.6. The rectangle below the boxes is called the _______控制焦点_________7. If this system represented part of a web site, what would B most likely represent?A web page.8. Why is C lower than A, B, D, and E?C is created by B.9. Why are A through G underlined?They are objects of corresponding class.10. Which of the following is an INV ALID sequence of messages, according to the diagram? ( B )A.1, 1.1, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.4.1B.1, 1.1, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.4.1, 1.1.5, 1.1.5.1C.1, 1.1, 1.1.1, 1.1.2, 1.1.3, 1.1.5, 1.1.5.1三、问答题(本大题共4小题,共25分)1. Please describe the risks of the software developing and the approaches to avoiding them (Score 8).User or business needs not metRequirements not addressedModules not integratingDifficulties with maintenanceLate discovery of flawsPoor quality of end-user experiencePoor performance under loadNo coordinated team effortBuild-and-release issuesAvoiding approaches?2.Please outline the phases and workflows of RUP (Score 5) .Inception (初始阶段): Define the scope of projectElaboration (细化阶段): Plan project, specify features andbaseline architectureConstruction (构造阶段): Build the productTransition (交付阶段): Transition the product into end-usercommunity3. Please name and briefly describe the “4+1view”of software architecture adopted in RUP (Score 5).Use-case view+Logical view+Implementation view+Process view+Deployment view】用例视图,逻辑视图,实现视图,过程视图+部署视图4. Please describe the use case analysis steps in OOA/D (Score 7).补充用例说明。
华南理工大学Java语言程序设计课堂作业答案homework01 2011-02-21 13:59 1. 编写一个类(控制台), 输入你的名字, 回车后, 向屏幕输出信息\欢迎你, ***\类似字样 2. 使用命令行模式编译,执行该程序, 将class文件指定输出到class目录 3. 给类添加move(), turnLeft(), pickPeeper(), putPeeper() 等方法, 并在Main中调用显示相关信息 4. 给类和各方法添加注释, 并使用javadoc指令输出代码文档Homework01 1. 编写一个类(控制台), 输入你的名字, 回车后, 向屏幕输出信息\欢迎你, ***\类似字样; () 2. 使用命令行模式编译,执行该程序, 将class文件指定输出到class目录; (现class文件夹在D:/目录下,控制台命令输入:javac -d D:\\class ) 3. 给类添加move(), turnLeft(), pickPeeper(),putPeeper() 等方法, 并在Main中调用显示相关信息; 4. 给类和各方法添加注释, 并使用javadoc指令输出代码文档. (现新建doc文件夹在D:\\下以存储文档,控制台输入:javadoc -d D:\\doc ) homework02 2011-02-27 22:32 修路工: 请使用分附件中的空白项目,装载sample03_holes_ 背景,修缮1st Street。
/* * File: * -------------------------- * The SampleKarel subclass as it appears here does nothing. */ import *; /* * Name: * Section Leader: */ public class SampleKarel extends SuperKarel {int count = 0; public void run() { // You fill in this part while(count } if (frontIsBlocked() || rightIsClear()) { changeDirection(); } move(); public void changeDirection() {if (rightIsClear()){ turnRight(); } else { if (leftIsBlocked()) {} } if (rightIsBlocked()) { turnRight(); turnRight(); } turnRight(); if (rightIsBlocked()) { turnLeft(); } } public static void main(String args) { String newArgs = new String[ + 1]; (args, 0, newArgs, 0, ); public void judgeAndPick() {} if (beepersPresent()) { pickBeeper(); } count++; }} newArgs = \ public String className() { return ()[1].getCanonicalName(); } }.clas sName(); (newArgs); homework03 2011-03-07 16:07 使用之前的空白项目,装载*collect* .w 背景,收集全部的Beeper. /* * File: * -------------------------- * The SampleKarel subclass as it appears here does nothing. */ import *; public class CollectAllBeepers extendsSuperKarel { /** * Through the maze* @author 黄泽津*/ public void run() {collect(); while(frontIsBlocked()&&!leftIsBlocked() ){if(facingEast()) { turnLeft();move(); turnLeft(); collect(); } if(facingWest()) {turnRight(); move(); turnRight(); collect(); }} } private void collect() {while(beepersPresent()){pick Beeper();} if(frontIsBlocked()) {return;} else move();collect();} public static void main(String args) { String newArgs = new String[ + 1]; (args, 0, newArgs, 0, ); newArgs = \public String className() { return ()[1].getCanonicalName();} }.className(); (newArgs);} }homework04 迷宫收集2011-03-13 21:47 创建迷宫world并放置一定的Beeper,装载该World后,收集全部的Beeper, 发送时请携带该world地图int count = 0; public void run() { //You fill in this part while(count judgeAndPick(); if (frontIsBlocked() || rightIsClear()) { changeDirection(); } move(); }public void changeDirection() {if (rightIsClear()) { turnRight(); } else { if (leftIsBlocked()) { turnLeft(); } } turnLeft(); }public void judgeAndPick() {} if (beepersPresent()) { pickBeeper(); count++; } homework05 迷宫收集2011-03-26 21:54 1. 从文件中构造二维世界, 文件为文本模式文件, 字符’0’ ‘1’组成 2. 构造该世界最下方地平面处的路面曲线, 以简单直观的方式在文本中打印, 路面可用’*’表示3. 可将Ship, Person的行进路线以以简单直观的方式在各自独立的文本中打印, 行进路线可用’*’表示/** * */ package map; import *; import *; /** * @author guhonglueying * */ // map 生成方法之从文件中读取public class FileMap extends SubMap {} catch (IOException e) { (); } charArr = new char[()]; for (int i = - 1; i > -1; i--) { } charArr[i] = (); try {FileReader fr = new FileReader(s[0]); BufferedReader bw = new BufferedReader(fr); while ((str = ()) != null) { (()); } // 重写父类create方法,用于从文件中读取新地图public void create(String... s) { String str = null; Stack stk= new Stack(); } } /** * */ package map; /** * @author guhonglueying * */ // map生成方法之程序中定义map public class SimpleMap extends SubMap { // 重写父类create方法,用来从程序中创建新地图} /** * */ package map; } charArr = new char {{ ‘0’, ‘0’, ‘1’, ‘1’, ‘1’, ‘0’, ‘0’, ‘0’ }, { ‘1’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘1’, ‘0’ },}; { ‘0’, ‘0’, ‘0’, ‘1’, ‘1’, ‘0’, ‘1’, ‘0’ }, { ‘0’, ‘1’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’ }, { ‘0’, ‘1’, ‘0’, ‘1’, ‘0’, ‘1’, ‘0’, ‘0’ }, { ‘0’, ‘0’, ‘0’, ‘1’, ‘0’, ‘0’, ‘0’, ‘1’ }, { ‘1’, ‘1’, ‘0’, ‘0’, ‘0’, ‘1’, ‘0’, ‘1’ }, { ‘1’, ‘1’, ‘1’, ‘1’, ‘1’, ‘1’, ‘0’, ‘0’ } public void create(String... s) { /** * @author guhonglueying * */ // 生成map的抽象类,用来定义map的一些public属性和方法public abstract class SubMap {} /** * */package map; public void setCol(int col) { } = col; int row; int col; char charArr; public void setRow(int row) { = row; } public int getRow() { return row; } public int getCol() { } return col; // 抽象方法,在子类中实现新地图生成的不同实现public abstract void create(String... s); public char getMap() {} = ; = charArr[0].length; return charArr; import *; import *; /** * @author guhonglueying * */ // map生成方法之从标准输入流获取public class SystemInMap extends SubMap {InputStreamReader isr = new InputStreamReader(); BufferedReader bw = new BufferedReader(isr);(\请用以下字符输入一方形地图:\\n1-墙,0-路,@-入口,#-出口\\n每次输入一行回车,输入E结束\} } while ((str = ()) != null) { if ((\ }break; } (()); // 重写父类create方法,用于从命令操作符中读取新地图public void create(String... s) {String str = null; Stack stk = new Stack(); try { } catch (IOException e) { (); } charArr = new char[()]; for (int i = - 1; i > -1; i--) { charArr[i] = (); } /** * */ package objectmovable; import util.*; /** * @author guhonglueying * */ // 实现person的走迷宫过程public class Person extends SubObjectMovable {} public void Maze(char ch) { (\ } h = new Helper(ch); (); (, 2); /** * */ package objectmovable; import util.*; /** * @author guhonglueying * */ // 实现ship的走迷宫过程public class Ship extends SubObjectMovable {public void Maze(char ch) { (\/** * */ package util; /** * @author guhonglueying * */ public class Node {public Node(int x, int y) { = x; = y; } public int getX() { } return x; private int x; private int y; public Node() { } public void setX(int x) { = x; } public int getY() { return y; } public void setY(int y) { } public boolean equals(Object o) { if (!(o instanceof Node)) = y; } } return false; Node n = (Node) o; return == x && == y; public String toString() { } return x + \ /** * */ package test; import map.*; import objectmovable.*; /** * @author guhonglueying * */ public class TestMaze {/** *@param args */ // 主函数,程序入口public static void main(String args) {} //多态实现:三种方式创建迷宫SubMap sm = new SimpleMap(); (); char c = (); //多态实现不同物体的走迷宫过程SubObjectMovable iom = new Ship(); (c); } homework07 文件处理2011-04-08 22:19 1. 读文件, 添加或去掉行号后写回 2. 统计一个文件中的词个数(请注意中文) package sample; import *; public class AddRowNum {// // // // // // // // // // (\(\(\(\(\(\(\(\return; try { /** 开启两个文件, 分别读写*/ BufferedReader reader = new BufferedReader(new FileReader(\ BufferedWriter writer = new BufferedWriter( new FileWriter(\/** 首先取得总行数, 然后逐行添加写回*/ int nRowNum = 0; String strOneLine = null; while (() != null) { }nRowNum++; public static void main(String args) { (); String formator = (\nRowNum = 0; reader = new BufferedReader( new FileReader(\while ((strOneLine = ()) != null) { ((\ %s\\n\++nRowNum, strOneLine)); }} package sample; import *; public class CountWords {public static void main(String args) {String fileName = \try {BufferedReader reader = new BufferedReader(newFileReader(fileName)); int NumberCount = 0; int LetterCount = 0; int ChineseCharacterCount = 0; int a = -1; } (new File(\ (); (); new File(\new File(\} catch (FileNotFoundException e) { (\找不到指定文件\} catch (IOException e) { (\文件读写错误\} Character c; while ((a = ()) != -1){ c = (char) a; if ((c)) { NumberCount++;} else if (‘\一’ ChineseCharacterCount++; } else if ((c)) { LetterCount++; } } (); (\文件\共包含:(\数字:\字母:\ + LetterCount + \汉字:\/** 林启敏*/ (); reader = new BufferedReader(new FileReader(\boolean isWordStart = false; int count = 0; char oneChar = new char[1]; while ((oneChar) != -1) { if (oneChar[0] == ‘.’} } || oneChar[0] == ‘,’ || oneChar[0] == ‘ ‘) { if(isWordStart) { } isWordStart = false; count++; \ else { } isWordStart = true; (\} catch (FileNotFoundException e) { (\找不到指定文件\} catch (IOException e) {} } } (\文件读写错误\homework08 html 2011-04-11 16:24 1. 使用Html实现登录页面, 需提供身份证号码, Email等相关信息 2. 在提交时, 使用JavaScript 做校验, 如果失败, 则提示注册者. 用户注册页面用户注册页面注册成功页面.oneColFixCtrHdr #container { width: 780px; background: #FFFFFF; margin: 0 auto; border: 1px solid #000000; text-align: left; } .oneColFixCtrHdr #header { background: #DDDDDD; padding: 0 10px 0 20px; } .oneColFixCtrHdr #header h1 { margin: 0; padding: 10px 0; } .oneColFixCtrHdr #mainContent { padding: 0 20px; background: #FFFFFF; font-weight: bold;} .oneColFixCtrHdr #footer { padding: 0 10px; background:#DDDDDD; } .oneColFixCtrHdr #footer p { margin: 0; padding: 10px 0; } --> 注册成功!下面自动转入首页...... homework09 Swing 2011-04-17 22:26 1. 使用Swing实现之前Html登录页面, 需提供身份证号码, Email等相关信息 2. 同样在提交时, 程序内部做校验, 失败则提示下相关信息. package homework09; import *; import *; import *; import *; import *; public class LoginWindow { public static void main(String args) {LoginFrame login = new LoginFrame();(\用户注册界面\(480,360); (null); (_ON_CLOSE);(true); } } class LoginFrame extends JFrame { public LoginFrame() { Font defaultFont = new Font(\微软雅黑\ Container loginCon = getContentPane(); LoginPanel panel = new LoginPanel(); TitledBorder inputPanelBorder = newTitledBorder(\基本资料\(defaultFont); (inputPanelBorder);(panel); } } class LoginPanel extends JPanel { JTextField nameField,phoneField,emailField,idCardFi eld; JPasswordField passField,repassField; JButton submit,reset; public LoginPanel() { BorderLayout layout = new BorderLayout();setLayout(layout); nameField = new JTextField(10); (()); passField = new JPasswordField(8); (());repassField = new JPasswordField(8); (()); phoneField = new JTextField(12); (());emailField = new JTextField(14); (()); idCardField = new JTextField(12); (());submit = new JButton(\提交\reset = new JButton(\重置\ Box horizontalBox1 = ();Box horizontalBox2 = ();BoxhorizontalBox3 = ();Box horizontalBox4 = ();Box horizontalBox5 = ();Box horizontalBox6 = ();Box horizontalBox7 = ();((35)); (new JLabel(\用户名:\((12)); (nameField); ((10));(new JLabel(\长度为8至16\(new JLabel(\设置密码:\((12)); (passField); ((10));(new JLabel(\长度至少为6\((30)); (new JLabel(\重复密码:\((12)); (repassField); ((10));(new JLabel(\两次输入必须一致\ ((60));(new JLabel(\电话号码:\ ((12));(phoneField);((10)); (new JLabel(\座机或电话号码\(new JLabel(\邮箱地址:\((12));(emailField); ((20));(new JLabel(\身份证信息:\((12));(idCardField);((52)); (submit); ((20)); (reset); Box verticalBox = (); (horizontalBox1); ((14)); (horizontalBox2); ((14)); (horizontalBox3); ((14)); (horizontalBox4); ((14)); (horizontalBox5); ((14)); (horizontalBox6); ((18)); (horizontalBox7);add(verticalBox);(new ActionListener() {public void actionPerformed(ActionEvent e) {submit(); } }); (new ActionListener() {public void actionPerformed(ActionEvent e) {} reset(); } }); void submit() { String phoneRe = \ String emailRe = \String idCardRe = \\Pattern phonePat = (phoneRe); Pattern emailPat = (emailRe); Pattern idCardPat = (idCardRe); Matcher phoneMat = (()); MatcheremailMat = (()); Matcher idCardMat = (()); String error = \ if(().equals(\ error = \用户名不能为空!\} else if(().length()16) { error = \用户名长度不符合要求!\} else if(().equals(\ error = \密码不能为空!\} else if(().length()else if(!().equals(())) { error = \两次输入的密码不一致!\} else if(().equals(\ error = \电话号码不能为空!\} else if(!()) { error = \电话号码格式不正确!\} else if(().equals(\ error = \邮箱地址不能为空!\} else if(!()) { error = \邮件地址格式不正确!\} else if(().equals(\ error = \身份证信息不能为空!\} else if(!()) { error =\身份证格式不正确!\}} if((\ } else (null, error, \消息提示\ _MESSAGE); (null, \注册成功!\消息提示\ _MESSAGE); reset(); void reset() {} } homework10 container 2011-04-24 22:461. 使用数组构建栈Stack(FILO) (null); (null); (null); (null); (null); (null);2. 对比Java提供的Stack, 两者有啥区别3. 使用Stack栈实现\行编辑器\设立一个输入行冲区, 接受用户逐行的输入, 处理后回显正确的信息逐行处理过程如下: 有两个特殊字符用来修改该行的错误信息, ‘#’表示之前一个字符错误, 请删除, ‘@’表示之前字符全部错误, 请删除前面的全部示例: whli##ilr#e(s#*s) -> while(*s) outcha@putchar(*s=#++); -> putchar(*s++); package mystack; /** * @author 电子商务一班俞国峰200930671251 */ public class MyStack {//currentSize用来记录当前栈中元素个数private int currentSize; private Object Mylist; //构造函数,创建空栈public MyStack(){ Mylist = new Object[10]; currentSize = 0; } //当数组长度不够时,增加数组长度public void enLargeSize() {} Object tempList = new Object[ * 2]; (Mylist, 0, tempList, 0, ); Mylist = tempList; //判断栈是否为空public boolean empty() { } return currentSize == 0; //入栈public void push(Object o) { if (currentSize >= ) { enLargeSize(); }} //出栈,返回栈顶元素public Object pop() {} //获取栈顶元素public Object peek() { if (currentSize == 0) {} } return null; if (currentSize == 0) { return null; } currentSize--; if (currentSize + 1 >= ) { enLargeSize(); } return Mylist[currentSize + 1]; Mylist[currentSize] = new Object(); Mylist[currentSize] = o; currentSize++;return Mylist[currentSize - 1]; //获取栈大小,返回栈中元素个数public int getSize() { } return currentSize; //清空栈public void clearAll() { } //重载toString(),以字符串形式返回栈中元素@Override public String toString() { Mylist = new Object[10]; currentSize = 0; } } String tempString = \for (int i = 0; i return tempString; package mystack; /** * @author 电子商务一班俞国峰200930671251 */ import *; public class testMyStack {public static void main(String args) {MyStack msk = new MyStack(); Scanner sc = new Scanner(); String input = \(\ \\nYou may enter in: enter ‘exit’ or ‘EXIT’ to exit!\ (\example: outcha@putchar(*s=#++);\(\ while (!(input =()).equalsIgnoreCase(\ char charr = (); (\for (int i = 0; i (charr[i]); switch (charr[i]) { case ‘#’:(); break; case ‘@’: (); break; } } } } } default : (charr[i]); break; (\(\ homework11 多线程和网络通信2011-05-07 21:59 1. 实现UDP模式的客户端和服务器端通信 2. 使用两个线程: 一个线程负责发送消息, 一个线程负责收取并发送消息,两线程间使用LinkedList共享数据package _yu_guo_feng; /* * @author 电子商务一班俞国峰200930671251 * * 功能:c/s结构,实现基于UDP的聊天功能* 说明:先开启服务器,再接入客户端* 未完善:服务器多开异常处理,下线提醒*/ import *; import *; import *; import *; import *; import *; public class Server extends JFrame {privatestatic final long serialVersionUID = 3497147855119919874L; private JTextArea jta; //保存当前用户private LinkedList sclient; private DatagramSocket socket; private DatagramPacket sendPacket, recevicedPacket; private byte buf; //日期处理private SimpleDateFormat sdf; public static void main(String args) { } new Server(); public Server() { String introduction QQ 730= 寝室版\ + \欢迎使用腾讯=================\\n\ + \+ \使用说明:\\n\+ \运行服务器\\n\+ \接入客户端(可接入多个)\\n\+ \功能:上线提醒、群聊和私聊\\n\ + \作者:电子商务一班——俞国峰——200930671251========\\n\ + \ try { socket = new DatagramSocket(8888); } catch (SocketException e) { ();jta =new JTextArea(introduction); ((new ImageIcon(\(\腾讯QQ 730寝室版——服务器\(jta, ); (400, 300); (false); (_ON_CLOSE); (null); (true); sclient = new LinkedList(); //指定时间表示模式sdf = new SimpleDateFormat(\。
企业战略管理模拟题1.战略管理实质上是使企业的资源和经营活动与其外部环境匹配协调。
(√)2.企业的外部环境分为宏观外部环境和其所处的产业环境。
(√)3.企业资源按其暂时性或可否及时调整来划分,可以分为有形资源和无形资源。
(×)4.符合独特的、难于模仿的和不可替代的标准的能力就是企业核心能力。
(×)5.对SWOT矩阵进行组合分析,WO组合应遵循的策略原则是通过外在的方式来弥补企业的弱点以最大限度地利用外部环境中的机会。
(√)6.新兴产业的企业最适合于开展集中化战略。
(×)7.在BCG矩阵图中,瘦狗有较低的市场增长率和较高的相对市场占有率。
(×)8.产业增长速度快会增加现有竞争对手间争夺的激烈程度。
(×)9.低成本战略的注意力集中于整体市场的一个狭窄部分,而集中化战略则以广大的市场为目标。
(×)10.衰退产业中的企业可以选择领先战略、坚壁战略、收获战略、快速放弃战略等竞争战略。
(√)11.全球化战略是指在不同国家市场销售标准化产品或服务,并由公司总部确定总体的竞争战略。
(√)12.组织结构除了受到战略的制约外,还受到企业规模、发展阶段、企业的环境等多方面因素的影响。
(√)13.管理与领导是有一定差别的。
管理主要处理变化的问题,而领导主要处理程序性、日常性和规范性的问题。
(×)14.公司治理的实质是解决公司所有权和经营权分离后所产生的代理问题。
(√)15.战略控制的重点是使公司内各种各样的活动保持一个总体的平衡。
(√)1.处于战略结构第二层次的是(D)。
A.公司战略B.职能战略C.市场战略D.经营战略2.战略管理系统的规范性通常与两个因素有非常大的关系,即企业的规模和企业所处的发展阶段,明茨博格认为,中小企业可能采取(B )。
A.计划性模式B.企业家模式C.适应性模式D.市场模式3.政府贷款和补贴对某些行业的发展也有着积极的影响,这种影响应该属于下列哪种因素?( A)A.经济因素B.技术因素C.政治-法律因素D.社会-人文因素4.分析资源的(D )的目的是确定一旦战略环境发生变化,企业资源对变化的适应程度。
四、程序阅读题 1、阅读以下程序,写出输出结果。 public class Abc { public static void main(String args[]) { Ab s = new Ab("Hello!", "I love JAVA."); System.out.println(s); } }
class Ab { String s1; String s2;
Ab(String str1, String str2) { s1 = str1; s2 = str2; }
public String toString() { return s1 + s2 + "You?"; } } Hello!I love JAVA。You? 2、阅读以下程序,写出输出结果。 public class Compare { public static void main(String[] args) { String str1 = "abc"; String str2 = new String("abc"); String str3 = "ab" + "c"; String str4 = new String(str2); String str5 = str1; System.out.println(str1 == str2); System.out.println(str2 == str3); System.out.println(str2 == str4); System.out.println(str5 == str1); } } False,false,false,true 3、阅读以下程序,写出输出结果。 public class GroupTwo { private int count;
public class Student { String name; public Student(String n1) { name = n1; count++; }
public void Output() { System.out.println(this.name); } }
public void output() { Student s1 = new Student("Johnson"); s1.Output(); System.out.println("count=" + this.count); }
public static void main(String args[]) { GroupTwo g2 = new GroupTwo(); g2.output(); } } Johnson Count=1 4、阅读以下程序,写出输出结果。 class superClass { int y;
superClass() { y = 30; System.out.println("in superClass:y=" + y); }
void doPrint() { System.out.println("In superClass.doPrint()"); } }
class subClass extends superClass { int y;
subClass() { super(); y = 50; System.out.println("in subClass:y=" + y); }
void doPrint() { super.doPrint(); System.out.println("in subClass.doPrint()"); System.out.println("super.y=" + super.y + " sub.y=" + y); } }
public class inviteSuper { public static void main(String args[]) { subClass subSC = new subClass(); subSC.doPrint(); } } in superClass:y=30 in subClass:y=50 In superClass.doPrint() in subClass.doPrint() super.y=30 sub.y=50 5、阅读以下程序,写出输出结果。 public class GroupThree { private static int count; private String name;
public class Student { private int count; private String name;
public void Output(int count) { count++; this.count++; GroupThree.count++; GroupThree.this.count++; System.out.println(count + " " + this.count + " " + GroupThree.count + " " + GroupThree.this.count++); } }
public Student aStu() { return new Student(); } public static void main(String args[]) { GroupThree g3 = new GroupThree(); g3.count = 10; GroupThree.Student s1 = g3.aStu(); GroupThree.Student s1.Output(5); } } 6 1 12 12
6、阅读以下程序,写出输出结果。 class Mammal { private int n = 40;
void crySpeak(String s) { System.out.println(s); } }
public class Monkey extends Mammal { void computer(int aa, int bb) { int cc = aa * bb; System.out.println(cc); }
void crySpeak(String s) { System.out.println("**" + s + "**"); }
public static void main(String args[]) { Mammal mammal = new Monkey(); mammal.crySpeak("I love this game"); Monkey monkey = (Monkey) mammal; monkey.computer(10, 10); } } **I love this game** 100
7、阅读以下程序,写出输出结果。 public class Flower { int petalCount = 0; String s = "initial value"; Flower(int petals) { petalCount = petals; print("Constructor w/ int arg only, petalCount= " + petalCount); }
Flower(String ss) { print("Constructor w/ String arg only, s = " + ss); s = ss; }
Flower(String s, int petals) { this(petals); this.s = s; // Another use of "this" print("String & int args"); }
Flower() { this("hi", 47); print("default constructor (no args)"); }
void printPetalCount() { print("petalCount = " + petalCount + " s = " + s); }
void print(String s) { System.out.println(s); }
public static void main(String[] args) { Flower x = new Flower(); x.printPetalCount(); } } Constructor w/ int arg only, petalCount= 47 String & int args default constructor (no args) petalCount = 47 s = hi 8、阅读以下程序,写出输出结果。 class Cup { Cup(int marker) { System.out.println("Cup(" + marker + ")");