JAVA期末试题及答案 联系客服

发布时间 : 星期五 文章JAVA期末试题及答案更新完毕开始阅读

} }

class Student{

public static void main(String arg[]){ Student A=new Student();

Undergraduate B=new Undergraduate(); B.setName(\许翼\ B.setScore(95);

B.setDeparment(\信息工程系\ B.setMajor(\计算机网络\ B.show1(); } }

2.从键盘或者命令行输入3个数,求这三个数的最大值。 2. import javax.swing.JOptionPane; public class MaxNum {

public static String sum(int a,int b,int c,int d){ if(a>b){ d=a; } if(b>d){ d=b; } if(c>d){ d=c; }

return \你输入的三个数字中,最大的数是\ }

public static void main(String[] args) { int number1,number2,number3; try{

number1=Integer.parseInt(JOptionPane.showInputDialog(\ number2=Integer.parseInt(JOptionPane.showInputDialog(\ number3=Integer.parseInt(JOptionPane.showInputDialog(\ System.out.println(sum(number1,number2,number3,0)); }catch(NumberFormatException ne){

System.out.println(ne.toString()); }

System.exit(0); }

the first Number: \the second Number: \the third Number: \ }

3. import java.awt.*;

public class TestCenterPanel {

public static void main(String args[]) { new MyFrame3(300,300,600,400,Color.BLUE); } }

class MyFrame3 extends Frame{ //private Panel p;

MyFrame3(int x,int y,int w,int h,Color c){ super(\ setLayout(null); setBounds(x,y,w,h); setBackground(c);

Panel p = new Panel(null); p.setBounds(w/4,h/4,w/2,h/2); p.setBackground(Color.pink); add(p);

setVisible(true); } }