银行笔试题
参加几个银行的考试,科技类基本考基础知识,笔试想过关,很简单,只要把基础知识弄懂基本就没问题了。java基础知识+数据库基础知识,这篇博文基于《东莞农商银行》的笔试回忆写,科技类分成了两卷A卷和B卷,我做的是A卷,只附上编程题部分。其他的都记不起来了。
1、用JAVA编程设计一个银行账户类,其中包括以下内容,并用字符界面模拟存款和取款过程
package test; import java.util.Scanner; public class application { private String zh; private String password; private String openTime; private double je; private String Lever; public String getZh() { return zh; } public void setZh(String zh) { this.zh = zh; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getOpenTime() { return openTime; } public void setOpenTime(String openTime) { this.openTime = openTime; } public double getJe() { return je; } public void setJe(double je) { this.je = je; } public void ck(double je){ this.je=this.je+je; } public void qk(double je){ if(je>this.je){ System.out.print("存款余额不足"); } else{ this.je=this.je-je; } } public void setLever(int lever){ if(lever == 1){ Lever = "普通会员"; } else if(lever == 2){ Lever = "黄金会员"; }else{ Lever = "白金会员"; } } public static void main(String[] args){ application zh= new application(); zh.setJe(10000); zh.setOpenTime("2013.12.3"); zh.setPassword("123456"); zh.setZh("zhangsan"); System.out.println("欢迎观临模拟银行"); // Scanner scan = new Scanner(System.in); System.out.println("当前的帐户为"+zh.getZh()); System.out.println("当前余额为:"+zh.getJe()+"元 "); } }
2、求解n!
package test; import java.util.Scanner; public class jiecheng { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); long sum =1; for(int i=1;i<=n;i++){ sum = sum*i; // System.out.println(i+"!"+"="+sum); } System.out.println(n+"!"+"="+sum); } }
3、建立索引
为学生选课数据库中的Students,Courses,Reports三个表建立索引。其中Students表按Sno(学号)升序建唯一索引,Courses表按Cno(课程号)升序建唯一索引,Reports表按Sno(学号)升序和Cno(课程号)号降序建唯一索引
create index stu_sno on Student(sno);
create unique index rep_scno on Reports(Sno Asc;Cno Desc);
4、java中的继承关系理解
//父类 package test; public class Animal { public Animal(){ System.out.println("Animal Create"); } } //子类 package test; import test.Animal; public class Dog extends Animal { public Dog(){ System.out.println("Dog Create"); } public static void main(String[] args) { // Animal c = new Animal(); Dog cc = new Dog(); } } 运行结果是: Animal Create Dog Create 如果把 public Animal(){ System.out.println("Animal Create"); } 改成 public void Animal(){ System.out.println("Animal Create"); } 运行结果是:Dog Create
上例中,一个没有加void返回值的父类函数时构造函数,创建子类时先创建父类,加入了void时,父类的构造函数被隐藏,而其成为了普通方法