false
2.public class Test{
public static void main(String[] args){
int x = 100;
int y = 200;
if(x == y)
System.out.println("not equal");
else
System.out.println("equal");
}
}
運行結果:
equal
3.public class TestKnowleage5 {
public static void main(String[] args){
try{
new TestKnowleage5().methodA(5);
}catch(IOException e){
System.out.println("caught IOException");
}catch(Exception e){
System.out.println("caught Exception");
}finally{
System.out.println("no Exception");
}
}
public void methodA(int i) throws IOException{
if(i%2 != 0){
throw new IOException("methodA IOException");
}
}
}
運行結果:
caught IOException
no Exception
4.public class TestKnowleage5 {
static boolean isTrue(){
System.out.println("isTrue");
return true;
}
static boolean isFalse(){
System.out.println("isFalse");
return false;
}
public static void main(String[] args){
if(isTrue() || isFalse()){
System.out.println("|| operate return true");
}
if(isFalse() & isTrue()){
System.out.println("& operate return true");
}
}
}
運行結果:
isTrue
|| operate return true
isFalse
isTrue
5.public class TestKnowleage5{
public static void main(String args[]){
MyThread t = new MyThread();
t.run();
t.start();
System.out.println("A");
}
}
class MyThread extends Thread{
public void run(){
try{
Thread.currentThread().sleep(3000);
}catch(InterruptedException e){
}
System.out.println("B");
}
}
運行結果:
BBA或
BAB
6.class A{
void fun1(){
System.out.println(fun2());
}
int fun2(){
return 123;
}
}
public class TestKnowleage5 extends A{
int fun2(){
return 456;
}
public static void main(String[] args){
A a;
TestKnowleage5 b = new TestKnowleage5();
b.fun1();
a = b;
a.fun1();
}
}
運行結果:
7.class A{
int val;
public int getVal() {
return val;
}
public void setVal(int val) {
this.val = val;
}
}
public class TestKnowleage5{
public static void main(String[] args){
A data = new A();
ArrayList list = new ArrayList();
for(int i=100;i<103;i++){
data.setVal(i);
list.add(data);
}
int j = 0;
while(j<list.size()){
A tmp = (A)list.get(j);
System.out.println("list("+j+")="+tmp.getVal());
j++;
}
}
}
運行結果:
list(0)=102
list(1)=102
list(2)=102
8.hibernate導入大量數據時,為了避免內存中產生大量對象,在編碼時注意什么,如何去除?
9.視圖與表的區別
10.觸發器有哪幾種類型
11.
事務操作有那幾個步驟
12.寫出對應正則表達式:
1)1-6位字母或數字;
[a-zA-Z0-9]{1,6}
2)手機號(只能是139或159開頭,11位數字)
1[35][9][0-9]{8}
13.字符串反轉:new StringBuilder(str).reverse().toString();
14.寫程序:1+2²+3²+...+n²
int func(int n){
return n==1?1:func(n-1)+n*n
}
15.寫一個延遲加載的單例模式:
public class SingleTon{
private static SingleTon instance = null;
private SingleTon(){}
public static SingleTon getInstance(){
if(instance == null){
synchronized(""){
if(instance == null){return new SingleTon();}
}
}
return instance;
}
}
16.
JSP的9種內置對象:request:
HttpServletRequest類的實例,客戶端的請求信息被封裝在request對象中response:
HttpServletResponse類的實例,response對象包含了響應客戶請求的有關信息,但在JSP中很少直接用到它。out:
out對象是JspWriter類的實例,是向客戶端輸出內容常用的對象session:
session對象指的是客戶端與服務器的一次會話,從客戶端連到服務器的一個WebApplication開始,直到客戶端與服務器斷開連接為止。它是HttpSession類的實例page:
page對象就是指向當前JSP頁面本身,有點象類中的this指針,它是java.lang.Object類的實例application:
ServletContext類的實例,application對象實現了用戶間數據的共享,可存放全局變量。它開始于服務器的啟動,直到服務器的關閉exception:
exception對象是一個例外對象,當一個頁面在運行過程中發生了例外,就產生這個對象。如果一個JSP頁面要應用此對象,就必須把isErrorPage設為true,否則無法編譯。他實際上是java.lang.Throwable的對象pageContext:
pageContext對象提供了對JSP頁面內所有的對象及名字空間的訪問,也就是說他可以訪問到本頁所在的SESSION,也可以取本頁面所在的application的某一屬性值,他相當于頁面中所有功能的集大成者,它的本類名也叫pageContextconfig:
config對象是在一個Servlet初始化時,JSP引擎向它傳遞信息用的,此信息包括Servlet初始化時所要用到的參數(通過屬性名和屬性值構成)以及服務器的有關信息(通過傳遞一個ServletContext對象)17.session和cookie的區別?
18.JDBC的操作步驟?