java 复习

来源:互联网 发布:无法telnet 端口 编辑:程序博客网 时间:2024/04/30 21:21

1. JVM, 跨平台


2. java application & java applet


3.  .java-> byte code->JVM (JRE) -> native OS code


4. If you have n class defined in your .java program file, after compiling, there would be n .class files


5. java GUI needs import package java.awt.* ;  to handle the event, we need import package java.awt.event.*


6. basic data types: int float, double . Java also has some reference data type, double -> Double Class, char -> Character class.


7. case sensitive


8. System.out.println("The value of b = "+ b);


9. User input data is always "string". not int. 

using Integer.parseInt(b) can convert string b to int b

using Double.valueOf(b).doubleValue() can convert string b to double b


10. FirstString = MyDouble.toString()

MyDouble has been converted to the FirstString


11.  Usually for our user defined class, we'd better define a constructor. If no, java treats it as a null constructor. No error


12. Abstract class cannot create a new object. Such class can be just extended by its sub class


13. statistic domain of a class. such domain would not save in any object's memory. Shared by each objects of this class.

final domain of a class. cannot be changed any more

e.g. static final String str = "hhhh"


14.  static initializer 静态初始化器 , which is different with the constructor


15. abstract methods can just appear in the abstract class. If a class extends this abstract class, such class should implement all its abstract methods


16. static domain or methods just belong to the class rather than any object.  Any static domain can just use static methods. When we call the static domain or methods, we need utilize the corresponding class rather than the object.


17. Package  is  defined as a set of classes.

18. Class can be public or default. For the domain or methods in a particular class, 

private: can not be shared by the sub class

default: can be shared by the class in the same package


19.  Multiple Inheritance: C++, Lisp, python, perl

Single Inheritance: java, Ruby, C#,  can achieve multiple inheritance by protocol or interface


20. Domain Inheritance

      Domain Hide: If we define a domain having the same name with a domain in its father's class, such father's domain would be hidden. (见书)

Methods Overload(方法重载,覆盖):见书,所有参数列表,定义头都必须一样,否则父类方法就不会被覆盖


21. this : the reference(引用) for the currentobject。 reference can be treated as another name of the current obj. 

在类的code中,this 表示实现这个class的object。


e.g class Employee{

 int age;

String name;

Employee( int age, String name){

this.age = age;

this.name = name;

}

}


22. super: the reference for the father's class. 


23. Polymorphism 多态:表示一个程序中同名的不同方法的情况. 实现方法有,

overload:

override:


24. The constructor of the current class and its father's class. Strictly speaking, the subclass would not inherit the constructor of father's class.

        1) if there's no constructor defined in the subclass, the constructor with no parameter of father's class would be called when we create a subclass object.

2) if there's is a constructor defined in the subclass, when we create a subclass object, firstly call the constructor with no parameter of father's class, and then call the subclass constructor

3) if we utilize the super expression to call the constructor of father's class, java would not call the constructor with no parameter of father's class. Note: the super expression should be written at the first row of subclass constructor. 


25. The class within the same package should not appear name conflict. 


26. One java source code file is called a compiling unit. Such file can just have one public class, its class name is the same with the file name. 


27. CLASSPATH specify the directory path for searching the package.


28. Interface: a special class just having Contant and abstract methods. can help achieve multiple inheritance.

We use the term implement rather than the term inherit. 

29. When we implement the abstract methods of an interface, we should add the "public" for the implemented methods.

0 0
原创粉丝点击