Review
Review
A Java class can only extend one parent class. Multiple inheritance using classes is
not allowed.
An interface can extend more than one parent interface. Multiple inheritance using
interface is supported
excute once when the class is first loaded into the Java virtual machine, before
main method is called.
String contains methods that don’t change string, StringBuffer contains methods
that change string
Like object of String classes, objects from wrapper classes are immutable (can’t
change)
Or Pattern.matches(regex, str);
str.matches(regex);
str.matches(“a*b”);
volatile keyword: is used for variable, so can modify the value of a variable by
different threads
Outer/ Enclosing class (Lớp bao): can not access members of nested class, but
can access through object
Nested class (Lớp lồng): Only known in outer class.
o static nested class (lớp lồng tĩnh): the same as static method
can access directly static members, can not access directly object members
in outer class but can access through object.
o nonstatic nested class/ inner class (lớp lồng phi tĩnh/ lớp nội bộ): the
same as object method
A x=new B();
• Ex:
Accessing data in a file (FileNotFoundException)
Read a text line from standard input device (IOException)
Accessing a remote resource.
Accessing data in a database.
• Ex:
Accessing an element of an array (ArrayIndexOutOfBound)
Access members of object (NullPointerException)
Divide by zero (ArithmeticException)
Method has been passed an illegal argument (IllegalArgumentException)
Parses the string as a number (NumberFormatException)
Polymorphism
• Static polymorphism is polymorphism that occurs at compile time, such as
method overloading
• Dynamic polymorphism is polymorphism that occurs at runtime, such as method
overriding (in class that implements interface or extends abstract superclass/
superclass)