首页 > 软件 > java程序题

java程序题

软件 2022-10-03

简单的java程序题

public class student{ private string stuid; private string stuname; private char stusex; private int stuage; /** *以下是各属性的getter/setter方法 */ public void setstuid(string stuid){ this.stuid=stuid; } public string getstuid(){ return stuid; } public void setstuname(string stuname){ this.stuname=stuname;

java程序题

abstractclassShape{
publicabstractvoiddsplse();
}
publicclassCircleextendsShape{
publicvoiddsplse(){
System.out.println("Iamcircle");
}
}
publicclassRectangleextendsShape{
publicvoiddsplse(){
System.out.println("IamRectangle");
}
}
publicclassTest{
publicstaticvoidmain(String[]agrs){
Circlecircle=newCircle();
circle.dsplse();
Rectanglerectangle=newRectangle();
rectangle.dsplse();
}
}

一道简单的java编程题?

import java.text.ParseException; import java.text.SimpleDateFormat; //日期类 public class Date { private String year; private String month; private String day; public Date(String year, String month, String day) { this.year = year; this.month = month; this.day = day; } public void format(){ System.out.p

java编程题 希望大家能够帮助我一下,谢谢?

package book;

/**

* @Author: Cool_Wu

* @Date: 2020-12-07 20:18

*/

public class Book {

private String name;

private String num;

private String author;

private double price;

private String publishing_House;

private String publication_Date;

public Book() {}

public Book(String name, String num, String author, double price, String publishing_House, String publication_Date) {

this.name = name;

this.num = num;

this.author = author;

this.price = price;

this.publishing_House = publishing_House;

this.publication_Date = publication_Date;

}

@Override

public String toString() {

return "图书信息:\n----------------------" +

"\n书名:" + name +

"\n书号:" + num +

"\n作者:" + author +

"\n单价:" + price +

"\n出版社:" + publishing_House +

"\n出版日期:" + publication_Date +

"\n----------------------\n";

}

}


package book;

public class Test {

public static void main(String[] args) {

Book book1 = new Book("百年孤独","10000","加西亚·马尔克斯",40.00,"南海出版公司","2017年08月");

System.out.println(book1);

Book book2 = new Book("时间简史","10086","史蒂芬·霍金",22.50,"湖南科技出版社","2014年06月");

System.out.println(book2);

}

}


运行结果

java编程题?

使用Random类和for循环输出0~100内的随机整数


importjava.util.Random;
publicclassRandomPrint{
publicstaticvoidmain(String[]args){
Randomr=newRandom();//不传入种子
for(inti=0;i<8;i++){
System.out.println(r.nextInt(100));
}
}
}

标签:编程 信息技术 Java Java编程 Java程序员

大明白知识网 Copyright © 2020-2022 www.wangpan131.com. Some Rights Reserved. 京ICP备11019930号-18