
正文
java面向对象代码试题 java面向对象的简答题
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
java面向对象选择题
C
A 没有返回值
B 不能接受同类型的参数返回不同的类型
D 返回值和类型不匹配
相关问答
Q1: Java面向对象程序设计题
1.Object
2.final
3.Object
4.this,super
一、读程序写结果
1.100
2.
数组a:123456,200,300
数组b:123456,200,300
数组bjava面向对象代码试题的长度: 3
3.
a=10
b=30
c=60
Q2: 1道JAVA面向对象的练习题,最后不懂!求助!
//防御方法通过输入参数接收攻击力,如果攻击力小于防御力,生命值不受影响,反之伤害值=攻击力-防御力
public void recovery(int attack){
recovery(15) 是你自己本身定义的方法,用来判断攻击力和防御能力的大小从而去改变他们的生命值。
比如就你那参数 15来说。 攻击是15 防御才10 所以对象会受到15-10=5的伤害
Q3: Java面向对象程序设计.哪位JAVA高手,帮我做一下下面的编程试题...
第一题
public class AirCondition extends Device {
private String dName;//空调名称
private String address;//空调厂家
private double price;//空调价格
private int temperature;//空调的温度
public AirCondition(String dName, String address,double price,int temperature) {
this.dName = dName;
this.address = address;
this.price = price;
this.temperature = temperature;
}
//给空调升温temp度
public void raiseTemp (int temp) {
this.temperature += temp;
}
//给空调降温temp度
public double lowerTemp(int temp) {
return this.temperature -= temp;
}
public String getdName() {
return dName;
}
public void setdName(String dName) {
this.dName = dName;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getTemperature() {
return temperature;
}
public void setTemperature(int temperature) {
this.temperature = temperature;
}
public String toString() {
StringBuffer r = new StringBuffer();
r.append("设备名称: " + getdName() + "\n");
r.append("出厂厂家: " + getAddress() + "\n");
r.append("价格: " + getPrice() + "\n");
r.append("初始温度: " + getTemperature() + "\n");
return r.toString();
}
}
第二题
import java.io.DataInputStream;
import java.io.FileInputStream;
public class Score {
private Object[][] data = new Object[10][2];//存放学好和密码
public static void main(String[] args) {
new Score().readData();
}
//读取数据
public void readData(){
DataInputStream dis = null;
try {
dis = new DataInputStream(new FileInputStream("studentdata"));
for(int i = 0; i data.length; i++){
data[i][0] = dis.readUTF();//学好
data[i][1] = dis.readInt();//密码
}
//调用计算
calc();
} catch (Exception e) {
e.printStackTrace();
}
}
//计算
public void calc(){
int total = 0;
double avg = 0;
int max = 0;
int min = 0;
Object[] temp;
for (int i = 0; i data.length; i++) {
for (int j = 0; j data.length - 1; j++) {
if((Integer)(data[j][1]) (Integer)(data[j + 1][1])){
temp = data[j];
data[j] = data[j + 1];
data[j + 1] = temp;
}
}
}
for (int i = 0; i data.length; i++) {
total += (Integer)data[i][1];
System.out.println("学号: " + data[i][0] + "\t" + "分数: " + data[i][1]);
}
avg = total / data.length;//平均
min = (Integer)data[0][1];
max = (Integer)data[data.length - 1][1];
System.out.println("最高分: " + max);
System.out.println("最低分: " + min);
System.out.println("平均分: " + avg);
}
}
Q4: java面向对象编程题目
public class Rectangle
{
private double width;
private double height;
//无参构造器
public Rectangle()
{}
//有参构造器
public Rectangle(double width, double height)
{
this.width = width;
this.height = height;
}
//属性的get和set方法定义
public void setWidth(double width)
{
this.width = width;
}
public double getWidth()
{
return this.width;
}
public void setHeight(double height)
{
this.height = height;
}
public double getHeight()
{
return this.height;
}
//计算周长的方法
private double getPerimeter()
{
return (width+height)*2;
}
//计算面积的方法
private double getArea()
{
return width*height;
}
public static void main(String[] args)
{
Rectangle rec = new Rectangle(3.6,5.8);
System.out.println("The perimeter of Rectangle is:"+rec.getPerimeter());
System.out.println("The area of Rectangle is:"+rec.getArea());
}
}
Q5: Java面向对象程序设计.哪位JAVA高手,帮我做一下下面的试题...
1、B;2、C;3、B;4、B;5、B;6、C;7、B;8、C;9、C;10、A;11、D;12、D;13、B;14、A;15、D
无聊哦~~~
三楼说java面向对象代码试题的不错!方法重载是指参数的个数与类型不一样!所以13题应该是Ajava面向对象代码试题,不过1题就是看不准那个下划线或减号java面向对象代码试题了java面向对象代码试题,呜呜~~
关于java面向对象代码试题和java面向对象的简答题的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






