Java Fundamentals Point of Review

Source: Internet
Author: User

Java Basic data types

Bollean 1

Char 2

BYTE 1, short 2, int 4, long 8

Float 4, double 8

-----------------------------------------------------

Four features of Java

Abstract, encapsulation, inheritance, polymorphic

----------------------------------------------------

Override and Overload

Override (Override): Subclass overrides Parent class method body, method name, return value, parameter unchanged.

Overload (Overloaded): Method name is the same, parameter is different (type, quantity).

-----------------------------------------------------

Abstract classes and Interfaces

Abstract classes: Abstract methods that contain (abstract) tags in a class must be abstract classes that are labeled (abstract), but there can be no abstract method in an abstract class.

Interface: A collection of abstract methods and constants. The public method and the final constant are all in the interface.

-----------------------------------------------------

Inheritance (extends) and implementation (implements)

Inheritance: Subclasses inherit the parent class to obtain the non-private (private) properties and methods of the parent class, and can override the member methods of the parent class;

The constructor method cannot be inherited, and if you want to call the constructor of the parent class super (), parameters can be added.

Implementation: Subclasses must override all methods of the interface.

------------------------------------------------------

Static code block and the Static keyword

Static code block: Static code blocks are loaded first when a class is loaded. A static block of code for a class can only be used once.

Static keyword: variables that are modified by static are global variables, and each object can use the same one;

The static modified method can be called with the class name. Method name, the static method can call the member method, the member method cannot call the static method, and the static method can only use the static tag's global variable.

--------------------------------------------------------

Modifier

This class Same package Sub-class Other Packages
Public Y Y Y Y
Protect Y Y Y
Default Y Y
Private Y

--------------------------------------------------------

String and StringBuffer

String: The immutable string.

StringBuffer: The string is mutable.

-------------------------------------------------------

Array

Arrays: The combination of data of the same type, fixed by the array length cannot be changed.

-------------------------------------------------------

Collection

Freq used: List,set,map

List: Sequential permutations can be repeated

Set: unordered permutations are not repeatable, only one null, (sort by hash table)

Map: Key-value pair combination, key cannot be duplicated, value can be repeated (hash table sort)

--------------------------------------------------------

Thread class and Runnable interface

Runable Interface: Runnable only provides a method run ().

Thread class: The thread class inherits the Runnable interface.

Thread on: Use object. The start () method opens the thread, and the Run () method is called when the thread is turned on.

-------------------------------------------------------

Synchronize process Sync Lock

Process synchronization: When synchronize marks a method or block of code, the secondary method or code block can have only one thread access at a time, and the other thread can access it only when the lock is released by the front-line.

-------------------------------------------------------

Yield () and join ()

Yield (): Pauses the current thread to execute another thread instead.

Join (): T.join () pauses the current thread to execute the t thread, and then resumes execution when T is finished.

-------------------------------------------------------

Wait () and notify (), Notifyall () and interrupt ()

Wait (): Causes the current thread to wait, the wait state releases the process synchronization lock, the wait state can be woken up by notify () or Notifyall (), and then resumes from waiting out.

Notify (): Randomly wakes up a waiting process with a lock.

Notifyall (): Randomly wakes all the waiting processes with locks.

Interrupt (): Thread. Interrupt () Converts the thread from sleep (), wait (), join () state to the interrupt state and throws an exception.

------------------------------------------------------

Inner class

Static Inner classes: Create classes in classes, static adornments, and only static properties and methods of the perimeter class can be called.

member Inner class: A class created in a class that cannot use the static modifier.

Anonymous inner class: Creates an object directly in the method.

Local inner class: A class that is created in the method body, has no modifiers, and can access only the final decorated constants.

-----------------------------------------------------

Java Fundamentals Point of Review

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.