java程序设计考试题及答案(有两道java编程题,因为我是学数据库的,很多java没接触过,求答案)

本文目录
有两道java编程题,因为我是学数据库的,很多java没接触过,求答案
public class Circle {
protected double r;
public Circle(double r){
this.r=r;
}
public Circle(){
this.r=10;
}
public double area(){
double area=0;
double r=this.r;
area=3.14*r*r;
return area;
}
public double perimeter(){
double per=0;
double r=this.r;
per=3.14*2*r;
return per;
}
}
public class PlainCircle extends Circle
{
double cX,cY;
public PlainCircle(double cX,double cY,double r) {
this.r=r;
this.cX=cX;
this.cY=cY;
}
public PlainCircle() {
this.cX=0;
this.cY=0;
this.r=10;
}
public boolean isInside(double x,double y){
if((x-cX)*(x-cX)+(y-cY)*(y-cY)《=r*r ){
return true;
}
else
return false;
}
}
几道JAVA题目,求好心人给下答案,感激不尽
1、public static void main(String args)
2、public finall static
3、3
4、抽象类
5、implements
6、类:一个包含属性、方法,使用class关键字定义
对象:创建对象必须使用new关键字,对象其实在内存中存储的是类的引用地址。
7、try是可能发生异常的内容;
catch是发生异常后要处理的代码;
finally是始终执行的,比如关闭资源等。
8、
public class Demo {
//小明今年12岁,他母亲比他大20岁。编程计算多少年后他母亲的年龄是小明的2倍。
public static void main(String args) {
System.out.println(getYeah());
}
public static int getYeah(){
int xmAge = 12,mqAge = 20,yeah = 0;
while(true){
if(mqAge / 2 == xmAge){
return yeah;
}
mqAge++;
yeah++;
}
}
}
9、
public class Demo {
public static void main(String args) {
new Thread(new Piao()).start();
new Thread(new Piao()).start();
new Thread(new Piao()).start();
new Thread(new Piao()).start();
}
}
class Piao implements Runnable{
private static int piao = 1;
public void run(){
while(true){
synchronized(Piao.class){
if(piao 》 100){
System.exit(0);
}
System.out.println(Thread.currentThread().getName()+"出票:" + piao + "号");
piao++;
}
}
}
}

更多文章:
网址大全怎么卸载干净(如何将电脑浏览器中的金山毒霸网址大全完全删除)
2026年3月24日 15:00
网页设计教学(MOODLE在中职《网页制作》课程教学中的应用_dreamweaver网页制作)
2026年5月12日 17:32
广东省三大设计院(广州市有多少个电力设计院我知道有三个,分别是:)
2026年5月11日 20:25
永州宗元500千伏变电站在哪里?网站优化(SEO)的步骤是什么
2026年4月21日 22:29
台州自首网站(台州一男子酒后从10楼扔下自行车,喝醉酒的人有多可怕)
2026年4月25日 16:16















