java程序设计期末考试试题及答案 web程序设计题库
大家好,今天给各位分享java程序设计期末考试试题及答案的一些知识,其中也会对web程序设计题库进行解释,文章篇幅可能偏长,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在就马上开始吧!
计算机java程序设计与算法试题求解
1..java
2.编译和解释(混合型模式)
3.不执行
4.高级语言,
5.main
6.声明
7.char
8.
9.false(假)
10.没有
11.90
12.true
13.静态
14.局部变量
15. Integer.parseInt();
16. 5
17. break,continue,return
18.(int)(Math.random()*100);
19.定义一个double型的数组a。
实例化数组a,使它的大小等于10。
没有指定类型
20.对象、类和继承。
21.java_home变量值,path变量值
22.可以
23.10
24. 0
25. continue
26. boolean(布尔型)
27.(int)(Math.random()*6)
28. double
29.没有
30.顺序结构、选择结构、循环结构
31.没有这个题目(呵呵)
32.System.out.println(m+1);
33.变量X没有初始化,语法
34.//与/**/另外还有/***/;
35.10
36.数组名
37.float(浮点型)
38.y=(int)X;
39.一个,是程序开始执行的位置,成员变量和成员方法
40.public double a();
帮帮忙,谢谢了。面向对象程序设计(JAVA)试题
我的实训题,不知道对你有没有帮助哈。包含了参考答案。实验一://1.编写一个程序,能够从键盘上接收两个数字,然后计算这两个数的乘积并打印输出;//提示:从键盘输入采用System.in对象。 import java.io.*; public class test1{ public static void main(String[] args)throws IOException{ String a,b; int s,t; BufferedReader in=new BufferedReader( new InputStreamReader(System.in)); a=in.readLine(); s=Integer.parseInt(a); b=in.readLine(); t=Integer.parseInt(b); System.out.println(s*t);}}//2.编写一个程序,从文本框接收两个数字,然后计算这两个数的乘积并打印输出;//提示:两个输入框加一个按钮,通过点击按钮来触发事件。//编写一个程序,从文本框接收两个数字,然后计算这两个数的乘积并打印输出 import java.io.*; import java.awt.*; import java.awt.event.*; public class Test3 extends Frame implements ActionListener{ TextField f1=new TextField(10); TextField f2=new TextField(10); Button bt=new Button("等于"); public Test3(){ setLayout(new FlowLayout()); add(f1); add(f2); add(bt); bt.addActionListener(this); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0);}}); pack(); setVisible(true);} public static void main(String[] args){ Test3 t=new Test3();} public void actionPerformed(ActionEvent e){ System.out.println(Integer.parseInt(f1.getText())* Integer.parseInt(f2.getText()));}}实验二://1.编写用户输入的三个整数,比较并输出其中的最大值和最小值;(if) import java.io.*; public class Test3{ public static void main(String args[])throws IOException{ int m,n,p; String x,y,z; BufferedReader in=new BufferedReader( new InputStreamReader(System.in)); x=in.readLine(); m=Integer.parseInt(x); y=in.readLine(); n=Integer.parseInt(y); z=in.readLine(); p=Integer.parseInt(z); if(m>=n&&m>=p){ System.out.println("the max is"+m); if(n>=p){ System.out.println("the min is"+p);} else System.
Java程序设计,急求答案.
注释就不写了,将就着看吧
awt/swing的题目就算了,懒得写,很少用
1、声明一个类Person,成员变量有姓名、出生年月、性别。有成员方法以显示姓名、年龄和性别。
import java.text.SimpleDateFormat;
import java.util.Date;
class Person{
public Person(String name, Date birthday, boolean isMale){
super();
this.name= name;
this.birthday= birthday;
this.isMale= isMale;
}
private String name;
private Date birthday;
private boolean isMale;
public void showName(){
System.out.println("姓名:"+ name);
}
public void showBirthday(){
System.out.println("出生年月日:"
+ new SimpleDateFormat("yyyy年MM月dd日").format(birthday));
}
public void showSex(){
System.out.print("性别:");
if(isMale){
System.out.println("男");
} else{
System.out.println("女");
}
}
}
2、声明一个接口,将一个人的出生年份转换成年龄
public interface DateUtil{
public int DateToAge();
}
3、在类Shapearea中声明三个同名方法求圆、矩形和三角形的面积(三个方法有不同的参数)。
public class Shapearea{
static final double PI=3.1415926;
public static double getArea(double r){
return r*r*PI;
}
public static double getArea(double x,double y){
return x*y;
}
public static double getArea(double a,double b,double c){
double l=a+b+c;
return Math.sqrt(l*(l-c)*(l-b)*(l-a));
}
}
4、已知某一角度的值,求它的正弦值。
Math.sin(a);
5、由键盘输入两个字符串“10”和“20”,将他们转换成整数,然后计算并输出这两个数的和。
Scanner sc=new Scanner(System.in);
String str1=sc.next();
String str2=sc.next();
Integer int1=new Integer(str1);
Integer int2=new Integer(str2);
System.out.println("结果是:"+int1+int2);
6绘图
7、绘制一圆角矩形、实心普通矩形,分别使用不同的颜色。
8、绘制一多边形(至少4个顶点)和一空心弧线(长度和角度自定)。颜色自定。
9、绘制一折线(至少六个顶点)和一正方形。颜色自定。
10、创建一个String类的对象Str1和Str2,判断Str2是否str1的子串。如果是,输出str1中在子串str2后的字符串。
Scanner sc=new Scanner(System.in);
String str1=sc.next();
String str2=sc.next();
if(str1.contains(str2)){
System.out.println(str1.split(str2, 2)[1]);
}
11、声明一个矩形类Rectangle,其中有多个构造方法。用不同的构造方法创建对象,并输出矩形的周长和面积。
12、完成一小应用程序,实现用CardLayout布局摆放三个按钮(每张卡片上一个按钮,点击按钮换卡片。)
好了,关于java程序设计期末考试试题及答案和web程序设计题库的问题到这里结束啦,希望可以解决您的问题哈!