大连网站建设平台,网站开发程序,网站模板 简洁,wordpress 功能 wordpress.org一、java简答题#xff1a; 1.java中我们学过的数据库类型转换有几种#xff1f;分别是什么#xff1f;转换规则是什么#xff1f; 答#xff1a;两种#xff0c;自动类型转换和强制类型转换。 源类型大于目标类型时#xff0c;需要自动转换。 源类型小于目标类型时 1.java中我们学过的数据库类型转换有几种分别是什么转换规则是什么 答两种自动类型转换和强制类型转换。 源类型大于目标类型时需要自动转换。 源类型小于目标类型时需要强制转换。 2.java中变量的命名规范有哪些 答(1)前面是字母、、下划线开头(2)后面可以是数字、字母、、下划线开头 (2)后面可以是数字、字母、、下划线开头(2)后面可以是数字、字母、、下划线结尾 (3)不可以是java的关键词 3.java中我们学过的数据类型有哪些请使用这些数据类型分别声明一个变量并赋值。 答(1)int a 1; (2)double a 1.0; (3)String str “张三”; (4)char a ‘男’; (5)boolean flag true; 二、java手写代码题。 1.从键盘上输入三个数然后从小到大输出。
public static void main(String []args){Scanner sc new Scanner(System.in);System.out.println(请输入第一个数);int num1 sc.nextInt();System.out.println(请输入第二个数);int num2 sc.nextInt();System.out.println(请输入第三个数);int num3 sc.nextInt();int temp 0;if(num1num2){temp num1;num1 num2;num2 temp;}if(num1num3){temp num1;num1 num3;num3 temp;}if(num2num3){temp num2;num2 num3;num3 temp;}System.out.println(num1,num2,num3);}2.假设机票原价为5000元4-10月份头等舱打9折经济舱打8折。其余月份为淡季头等舱打5折经济舱打4折使用嵌套if实现。public static void main(String []args){int yuan 5000;//原价int xian 0; //现价System.out.println(请选择月份);Scanner sc new Scanner(System.in);int yue sc.nextInt(); //输入月份System.out.println(可选舱位1.头等舱 2.经济舱);System.out.println(请您选择舱位);int cang sc.nextInt(); //选择的舱位if(yue4yue10 ){//旺季if(cang 1){//头等舱xian yuan*0.9;System.out.println(yue月份头等舱的价格是xian);}else{//经济舱xian yuan*0.8;System.out.println(yue月份经济舱的价格是xian);}}else{//淡季if(cang1){//头等舱xian yuan*0.5;System.out.println(yue月份头等舱的价格是xian);}else{//经济舱xian yuan*0.4;System.out.println(yue月份经济舱的价格是xian);}}}三.SQL手写代码题。 已知表books 其中有列bno编号,bname名称,author作者,price价格,quantity库存册数 1.插入三条记录 insert into books values(1,‘狂人日记’,‘鲁迅’,18.5,100); insert into books values(2,‘老人与海’,‘海明威’,20,200); insert into books values(3,‘假如给我三天光明’,‘海伦.凯勒’,15,150) 2.查询表中的全部信息 select * from books; 3.查询作者为鲁迅的图书的书号、书名和单价 select bno ,bname,price from books where author ‘鲁迅’ 4.查询作者未鲁迅且价格不超过20的图书书名、价格、库存 select bname,price,quantity from books author ‘鲁迅’ and price20 5.查询book表中共有多少记录 select count(*) from books; 6.将书号为1的图书的库存在原有的基础上100 update books set quantity quantity100 where bno 1 7.将作者为鲁迅的图书修改为周树人 update books set author ‘周树人’ where author ‘鲁迅’ 8.delete from books where bno 2;