程序改错

程序改错

1、改正下面程序段中的错误(共5处)

public Class Test {  //1

    public static void main(String args) { //定义主方法2

        int i1,i2,i3;

        float f;

        char c;

        System.out.println("int:" + i1); //3

        c = “A”;                  //4

        f = 3.0;                   //5

    }

}

 

2、改正下面程序段中的错误(共5处)

public class Test {

    public void main(String[] args) {       //定义主方法1

        boolean isValid = 0;             //2

        int scores[5] = {65,70,69,98,86};  //3

        if( isValid ) then{               //4

           System.out.println(scores[5]);  //5

        }else{

           System.out.println(“No information”);

        }

    }

}

 

3、改正下面程序段中的错误(共5处)

public class Student{

   String id;

   Strng name;

   int salary;

   public void Test(String id, String name, int salary){ //1

      this.id = id;

      this.name = name;

      this.salary = salary;

   }

   public void changeInfo(String id, int salary){   //2

      boolean result;

      if(id == this.id){                       //3

         this.salary = salary;

         result = TRUE;                     //4

}else{

   result = false;

}

return result;

   }

   public boolean changeInfo(String ids, int salarys){ //5

     ……

   }

}

 

4、改正下面程序段中的错误(共5处)

import java.awt.*;

import java.awt.event.*;

public class MyFrame extends Frame{

   public MyFrame(){

      Button btn = new Button(“Exit”);

      setLayout(BorderLayout);  //1

      add(btn);              

      btn.addActionListener(this); //2

      setSize(300,300);

      setVisible(TRUE);   //3

}

   public static void main(String[] args){

      MyFrame fr = MyFrame();   //4

   }

   class MyHandler extends ActionListener{ //5

       public void actionPerformed(ActionEvent e){

         System.exit(0);

}

}

}

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值