java试卷22

public class Java_1 extends TT
{
   //*********Found**********
   public static void main(String args[])
   {
      Java_1 t = new Java_1("小龙");
   }
   public Java_1(String s)
   {
      super(s);
      System.out.println("您好吗?");
   }
   public Java_1()
   {
      this("我是文朋");
   }
}

class TT
{
   public TT()
   {
      System.out.println("多高兴啊!");
   }
   public TT(String s)
   {
   //*********Found**********
      this();## Java_1继承了TT类,按题目要求输出循序,应先输出TT类中无构造函数
      System.out.println("我是"+s);
   }
}
### 考察triple,有小数则,double;主函数条用了triple
public class Java_2
{
   public static void main(String[] args)
   {
      System.out.println("观察triple方法参数 double 10.0 的改变:");
      //*********Found**********
      double canshu = 10;
      //*********Found**********
      System.out.println("参数*3前,参数值为 " +canshu);
      triple(canshu);
      System.out.println("在triple方法外,参数值仍为 " + canshu);
      System.out.println("思考:方法能否改变参数值?");
   }
  //*********Found**********
   public static void triple(double x)
   {
      //*********Found**********
      x = x * 3;
      //*********Found**********
      System.out.println("在triple方法内,参数 10 变为 " + x);
   }
}

## 本题是向一个Javaswing程序提供要给窗口,则填JApplet;初始化JApplet是init方法;初始化种将奔雷的Label添加到全局种,则contentPane


import java.awt.*;
import javax.swing.*;

//*********Found**********
public class Java_3 extends JApplet
{
   //*********Found**********
   public void init ()
   {
      Container contentPane = getContentPane();
      JLabel label = new JLabel("One World  One Dream",SwingConstants.CENTER);
      label.setFont(new Font("Arial", Font.BOLD, DEFAULT_SIZE));
      //*********Found**********
      contentPane.add(label);
   }
   private static final int DEFAULT_SIZE = 24;
}

猜你喜欢

转载自blog.csdn.net/qq_38640439/article/details/82349490