1、设计一个矩形类,计算某一给定矩形的面积2、设有计算阶乘的函数f(n)=n!,试设计一个计算阶乘的方法和相应的类,并利用这个类计算f(5)和f(17)的值3、简述对象间的通信(消息)与实例方法的调用?4、定义一个代表学生的类Student,创建该类的3个对象放在一数组中,试将数组的元素依次输出。Student类的属性包括“学号”、“姓名”和“成绩”;方法包括“构造方法”、“获取学号”、“获取姓名”、“获取成绩"5、编程判断当前目录下是否存在文件file1.txt和file2.txt,如果都存在则将file1.txt的内容写到文件file2.txt中去6、简述Applet类的主要方法?7、编写一能接收参数的小应用程序,参数值为字符串“新年快乐”,并写出该小应用程序编译执行的过程8、编程计算从10到20的平方值,并将结果保存在一个数组中9、设有计算阶乘的函数f(n)=n!,试设计一个计算阶乘的方法和相应的类,并利用这个类计算f(5)和f(17)的值10、怎么样理解循环语言,并一实例来说明?
新手求助,很急很急,希望各位一定得帮我,在线等!!!
谢谢谢谢
很急

解决方案 »

  1.   

    这些题目还是自己做做吧,不然你学java干什么
      

  2.   

    各位大哥,请你们一定帮帮忙
    小弟真的很急
    我不是学JAVA的(骗你们我不是人),要是是拿来学习用的我绝对自己做
    希望你们一定要帮帮我.
    鞠躬感谢
      

  3.   


    //设计一个矩形类,计算某一给定矩形的面积
    public class RectangleArea 
    {
    public static double area(double l,double w)
    {
    double area=l*w;
    return area;
    }
    }
      

  4.   


    //设有计算阶乘的函数f(n)=n!,试设计一个计算阶乘的方法和相应的类,并利用这个类计算f(5)和f(17)的值
    public class Rank
    {
    public static int rank(int i)
    {
    int rank;
    for(int j=1;j<=i;j++)
    {
    rank*=j;
    }
    return rank;
    }
    }快给分,给了继续下面的题 快一点啊,你在线加分,我在线等分.
      

  5.   

    简述对象间的通信(消息)与实例方法的调用? 对象间的通信,假设对象A调用了对象B的方法,就是对象B用那个方法发消息给A静态方法(static)直接用类名调用.没有声明静态的方法就需要使用对象来调用,也就是实例化.
      

  6.   

    兄弟   都是很简单的题目啊
    为什么要求人呢?
    求人不如求己啊
    我们帮你是害你
    你说你不是学java的
    那要这些做什么啊
      

  7.   

    //TestStudent.java:测试类
    public class TestStudent
    {
       public static void  main(String[] args)
       {
         Student[] student=new Student[3];
         student[0]=new Student("001","张三","90");
         student[1]=new Student("002","李四","95");
         student[2]=new Student("003","王五","100");
         
         for(int i=0;i<3;i++)
         {
          System.out.println(student[i].toString());
         }
       }
    }
    //Student.java:学生类,包含一些基本信息
    class Student
    {
    private String stNumber;  //学号
    private String stName;    //姓名
    private String grade;     //成绩

    public Student(String number,String name,String grade)
    {
    this.stNumber=number;
    this.stName=name;
    this.grade=grade;
    }

    public String getNumber()  //获得学号
    {
    return stNumber;
    }

    public String getName()   //获得姓名
    {
    return stName;
    }

    public String getGrade() //获得成绩
    {
    return grade;
    }

    public String toString()
    {
    return "学号:"+stNumber+" 姓名:"+stName+" 成绩:"+grade;
    }
    }
      

  8.   

    第2题 最好的办法是使用递归
    public class A{public static int function(int n){
    if(n==1) return n;
    return function(n-1)*n;}public static void main(String args[]){System.out.println(function(5));
    System.out.println(function(7));
    }
    }
      

  9.   

    public class Student { /**
     * 学号
     */
    public String xh; /**
     * 姓名
     */
    public String xm; /**
     * 成绩
     */
    public int cj; public Student(String xh, String xm, int cj) {
    this.xh = xh;
    this.xm = xm;
    this.cj = cj;
    } public String getXh() {
    return xh;
    } public void setXh(String xh) {
    this.xh = xh;
    } public String getXm() {
    return xm;
    } public void setXm(String xm) {
    this.xm = xm;
    } public int getCj() {
    return cj;
    } public void setCj(int cj) {
    this.cj = cj;
    } public String toString() {
    return xh + "," + xm + "," + String.valueOf(cj);
    }
    }
      

  10.   

    经典,这个递归很漂亮。第2题 最好的办法是使用递归 public class A{ public static int function(int n){ 
    if(n==1) return n; 
    return function(n-1)*n; } public static void main(String args[]){ System.out.println(function(5)); 
    System.out.println(function(7)); 

    }
      

  11.   

    这个是最简单的JAVA题目,说白了就是简单的算法问题,我怀疑这个是不是你的作业?
      

  12.   

    第三题,第六题google上搜下,就有了
      

  13.   

    我也怀疑是你的作业
    不要这样啊  
    这样学JAVA不好的
    不自己动手 永远也学不会的 
    LZ加油把
      

  14.   

    你这个也太懒了吧
    不会java
      

  15.   

    //文件copy
    public static void main(String[] args) throws FileNotFoundException, IOException {
    File f1=new File("c:/f1.txt");
    File f2=new File("c:/f2.txt");
    if(f1.exists()&&f2.exists()){
    FileChannel channel1=new FileInputStream(f1).getChannel();
    FileChannel channel2=new FileOutputStream(f2).getChannel();
    channel1.transferTo(0,f1.length(),channel2);
    channel1.close();
    channel2.close();
    }

    }
      

  16.   

    lz你学过java不
      即使你没学过
      那google总会用吧~~~~
      

  17.   

    Applet?
    怎么现在还在考这个过时的玩意?
    楼主该不会大学考试吧?
      

  18.   

    第一题:
    /** 平面图形接口 */
    public interface PlaneGraphics { /** 计算面积的方法 */
    public  double area(); /** 计算周长的方法 */
    public  double perimeter(); /** 打印方法 */
    public  void print();
    }
    /**
     * 矩形类myRectangle实现平面图形接口PlaneGraphics
     * 其内封装了矩形面积、周长的计算.
     */
    public class MyRectangle implements PlaneGraphics {
    /** 矩形的长度 */
    protected double length; /** 矩形的宽度 */
    protected double width;

    /** 两个参数的构造方法 */
    public MyRectangle(double length, double width) {
    this.length = length;
    this.width = width;
    } /** 一个参数的构造方法,此时矩形为正方形 */
    public MyRectangle(double width) {
    this.length = width;
    this.width = width;
    }

    /** 无参的构造方法 */
    public MyRectangle() {
    //调用两个参数的构造方法
    this(0,0);
    }

    /** 计算矩形的面积 */
    public double area() {
    return this.length * this.width;
    }

    /** 计算矩形的周长 */
    public double perimeter() {
    return 2*(this.length + this.width);
    }

    /** 输出矩形的长度、宽度、面积、周长 */
    public void print() {
    if (this.length == this.width) {
    System.out.print("一个正方形,长度为 " + this.length);
    } else {
    System.out.print("一个长方形,长度为 " + this.length 
            + ",宽度为 " + this.width);
    }
    System.out.println(",面积为 " + this.area() 
              + ",周长为 " + this.perimeter());
    }

    //main()方法用来测试
    public static void main(String[] args) {
    MyRectangle r1 = new MyRectangle(10, 20);
    r1.print(); r1 = new MyRectangle(10);
    r1.print();
    }
    }
      

  19.   

    我来做 我这个比较标准 你要给我分哦:第一题的答案package taotao.montao.over;public class Rectangle { public static void main(String[] args) {
    CreateRectangle rectangle = new CreateRectangle(40,50);
    int area = rectangle.getArea();
    System.out.println("面积是: "+area);
    }
    }class CreateRectangle {
    int width = 0;
    int height = 0; public CreateRectangle(int width, int height) {
    this.width = width;
    this.height = height;
    }

    public int getArea()
    {
    int area = 0;
    area = this.height * this.width;
    return area;
    }
    }
      

  20.   

    第二题: package taotao.montao.over;public class TestJieChen { public static void main(String[] args) {

    System.out.println(cunt(5));

    }

    public static int cunt(int num)
    {
    int result = 1;
    if(num>0)
    {
    int i = 1;
    while(i<=num)
    {
    result = result*num;
    i++;
    }
    }
    return result;
    }
    }
      

  21.   

    第三题:
     JAVA程序创建对象,对象之间的交互是通过发送消息来实现的。(该理解可以参照3楼的小伙子的答案)
      

  22.   

    第四题package taotao.montao.over;public class StudentTest { public static void main(String[] args) {

    Student student1 = new Student(101,"montao",85.5f);
    Student student2 = new Student(102,"yangtao",98.5f);
    Student student3 = new Student(103,"taotao",87.7f); Object[] object = {student1,student2,student3};

    //打印
    for(int i=0;i< object.length;i++)
    {
    Student stu = (Student)object[i];
    System.out.println("----------学员信息----------");
    System.out.println("学员ID:"+stu.getStudentId());
    System.out.println("学员姓名:"+stu.getStudentName());
    System.out.println("学员分数:"+stu.getMark());
    }
    }
    }class Student
    {
    private int studentId;
    private String studentName;
    private float ;

    public Student(int id,String name,float )
    {
    this.studentId = id;
    this.studentName = name;
    this. = ;
    }

    public int getStudentId()
    {
    return this.studentId;
    }

    public String getStudentName()
    {
    return this.studentName;
    }

    public float getMark()
    {
    return this.;
    }
    }
      

  23.   

    第五题答案:
    package taotao.montao.over;import java.io.*;public class FileTest { public static void main(String[] args) { System.out.println(work());
    } public static String work() {
    String msg = null;
    File file1 = new File("H:/file1.txt");
    File file2 = new File("H:/file2.txt");
    BufferedReader br = null;
    String fileContent = "";
    // 判断是否存在
    if (file1.exists() && file2.exists()) {
    // 读出file1中的内容
    try {
    br = new BufferedReader(new FileReader(file1));
    String line = "";
    while ((line = br.readLine())!= null) {
    fileContent += line;
    }
    msg = "文件COPY已经成功!";
    } catch (Exception e) {
    e.printStackTrace();
    msg = "当前目录下不存在该文件或则读写失败!";
    } finally {
    try {
    br.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }

    //写文件
    BufferedWriter bw = null;

    try {
    bw = new BufferedWriter(new FileWriter(file2));
    bw.write(fileContent);
    } catch (Exception e) {
    e.printStackTrace();
    }finally
    {
    try {
    bw.flush();
    bw.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
    return msg;
    }
    }
      

  24.   

    第六题目答案:  destroy() 由浏览器或applet viewer调用,通知此applet它正在被回收,它应该销毁分配给它的任何资源。
      getAccessibleContext() 获取与此 Applet 有关的 AccessibleContext。
      getAppletContext() 确定此applet的上下文,上下文允许 applet 查询和影响它所运行的环境。
      getAppletInfo()返回有关此 applet 的信息。
      getAudioClip(URL url)返回 URL 参数指定的 AudioClip 对象。
      getCodeBase() 获得基 URL。 
      getDocumentBase() 获取嵌入了此 applet 的文档的 URL。
      getImage(URL url)   返回能被绘制到屏幕上的 Image 对象。
      getImage(URL url, String name) 返回能被绘制到屏幕上的 Image 对象。
      getLocale() 如果已经设置,则获取 applet 的语言环境。
      getParameter(String name) 返回 HTML 标记中命名参数的值。
      getParameterInfo() 返回此 applet 理解的关于参数的信息。
      init() 由浏览器或 applet viewer 调用,通知此 applet 它已经加载到系统中。
      isActive() 确定 applet 是否处于激活状态。
      newAudioClip(URL url)  从给定 URL 处获取音频剪辑。
      play(URL url) 播放在指定的绝对 URL 处的音频剪辑。
      resize(Dimension d)  请求调整此 applet 的大小
      setStub(AppletStub stub) 设置此 applet 的 stub。
      showStatus(String msg)  请求参数字符串显示在 "status window" 中。
      start() 由浏览器或 applet viewer 调用,通知此 applet 它应该开始执行。
      stop() 由浏览器或 applet viewer 调用,通知此 applet 它应该终止执行。
      

  25.   

     
     第七题 对不起 我没学过Applte 所以做不出来哦!
     
      对不起  
      

  26.   

    第八题:
    package taotao.montao.over;public class TestNum { public static void main(String[] args) {
    int[] num = work(10, 20);
    for (int i = 0; i < num.length; i++) {
    System.out.println(num[i]);
    }
    } public static int[] work(int start, int end) {
    int[] num = new int[end-start+1];
    int j = 0;
    for (int i = start; i < end+1; i++) {
    num[j] = i * i;
    j++;
    }
    return num;
    }
    }
      

  27.   


      第九题重复
      第十题目 自己上GOOGLE搜索一百 !!!!
      

  28.   

    我是刚刚接触JAVA,专业课,基础题还是自己多多锻炼的好
      

  29.   

    不是吧,大哥,如果你想要答案,你也不用这样发帖子要啊,你可以给某一个人的邮箱发email
      

  30.   

    public int Area(int width,int high){
    int width1;
    int high1;
    width1=width;
    high1=high;
    int area=width1*high1;
    return area;
    }//这是获得矩形面积的方法
    public int Jiecheng(int i,int k){
    int jiecheng=1;
    for(int j=1;j<=i;j++){
    jiecheng*=j;
    }
    return jiecheng;
    }//这是计算阶乘的方法