标签:
====================================
=======学而时习之========================
=====================
1.
public class Test { public static void main(String[] args) { String str = "123"; changeStr(str); System.out.print(str); } public static void changeStr(String str){ str = "abc"; } }
关键词:java内存分配
2.
public class Test { static boolean foo(char c) { System.out.print(c); return true; } public static void main(String[] args) { int i = 0; for (foo(‘A‘); foo(‘B‘) && (i < 2); foo(‘C‘)) { i++; foo(‘D‘); } } }
关键词:c for
3.
public class B extends A { // here } class A { protected int method1(int a, int b) { return 0; } } //Which two are valid in a class that extends class A? (Choose two) //A. public int method1(int a, int b) { return 0; } //B. private int method1(int a, int b) { return 0; } //C. private int method1(int a, long b) { return 0; } //D. public short method1(int a, int b) { return 0; } //E. static protected int method1(int a, int b) { return 0; }
关键词:override , overload
4.
public class Outer { public void someOuterMethod() { // Line 3 } public class Inner { } public static void main(String[] args) { Outer o = new Outer(); // Line 8 } } // Which instantiates an instance of Inner? // A. new Inner(); // At line 3 // B. new Inner(); // At line 8 // C. new o.Inner(); // At line 8 // D. new Outer.Inner(); // At line 8 // E. new Outer().new Inner(); // At line 8
关键词:内部类
5.
CREATE TABLE zxg(a VARCHAR2(10),b VARCHAR2(10)) INSERT INTO zxg VALUES(‘a‘,NULL); INSERT INTO zxg VALUES(‘b‘,‘234‘); INSERT INTO zxg(a,b) VALUES (‘c‘,‘‘); INSERT INTO zxg(a,b) VALUES (‘d‘,‘ ‘); SELECT * FROM zxg --1 a --2 b 234 --3 c --4 d SELECT * FROM zxg WHERE b LIKE ‘%‘ --1 b 234 --2 d
关键词:LIKE , NULL
6.
//final 是形容词最终的,final 类不可以被继承,final 字段不可以被改变,final方法不可以被重写 //The type A cannot subclass the final class B //Cannot override the final method from B //The final field A.s cannot be assigned //finally 是副词 try{}catch(){}finally{} //finalize() 是方法,垃圾回收机制
关键词:final , finally , finalize
7.
关键词:private , 缺省 , protected , public
8.
public class Test { public static void main(String[] args) { // 向上转型 Father f = new Child(); // f.mygirlfriendis(); // The method mygirlfriendis() is undefined for the type Father System.out.println(f.name); f.iam(); // 向下转型 if (f instanceof Child) { Child c = (Child) f; System.out.println(c.name); c.iam(); c.mygirlfriendis(); } } } class Father { String name = "Father"; public void iam() { System.out.println(this.name); } } class Child extends Father { protected String name = "Child"; public void iam() { System.out.println(this.name); } public void mygirlfriendis() { System.out.print("Xuhua"); } }
执行结果:
Father
Child
Child
Child
Xuhua
关键词:向上转型,向下转型
9.
public static void main(String[] args) { String s = null; System.out.println(String.valueOf(s)); System.out.println(String.valueOf(null)); }
关键词:方法重载
10. 引用是怎么回事
Circle c; | c | null | ||
c = new Circle(); | c | 0x45f | → | c:Circle |
radius:0 |
Circle c; 和 Circle c = null; 的区别
class Test { Person person; public void f() { // Person xx; // System.out.println(xx); //The local variable xx may not have been initialized System.out.println(person); } } class Person { }
标签:
原文地址:http://www.cnblogs.com/zno2/p/4485592.html