2021-01-05 java-oop考前知识整理

类、对象,抽象类、封装、继承、多态、动态绑定,覆盖、重载,接口,异常处理、事件驱动编程

 

Class:

  1. Class are constructs that define objects of the same type;
  2. Class contains {variables / constructor / method}

 

Object:

  1. State and behaviour

Constructor

  1. Constructors are a special kind of methods that are invoked to construct objects.
  2. Constructor plays the role of initializing objects.
  3. 1. Constructor must have the same name as the class itself;

2. Constructor don’t have a return type---not even void;

3. Can be no-arg constructor

 

Abstract class:

  1. An abstract method can not be contained in nonabstract class.
  2. Class abstraction means to separate class implementation form the use of the class.

 

Encapsulation:

  1. The user of the class doesn’t need to know how the class is implemented. The details of implementation is encapsulated and hidden from the user.

 

Inheritance:

  1. Avoid redundancy of the classes with many common features.
  2. The superclass’s constructor can’t be inherited. They are invoked explicitly or implicitly.

 

Polymorphism:

  1. An object of a subtype can be used wherever its supertype value is required.
  2. Casting: be used to convert an object of one class type to another within an inheritance hierarchy.
  3. Casting from superclass to subclass: explicit casting, may not always succeed.
  4. Casting from subclass to superclass: always succeed. The special methods in subclass can’t be used anymore.

 

Dynamic binding:

The JVM dynamically binds the implementation of the method at runtime.

 

Overloading:

The ability to create multiple methods of the same name with different implementation.

 

Overriding:

Subclass to modify the implementation of a method defined in the superclass.

 

Interface:

  1. An interface is a class-like construct that contains only constants and abstract methods.
  2.  The intent of an interface is to specify common behavior for objects.(comparable cloneable edible )
  3. All data fields are public static final and all methods are public abstract in an interface.

 

Exception handling:

  1. Try-catch
  2. Throws-throw
  3. Unchecked error: errors and runtime exception

 

Event-driven programming:

Timer / event / listener /

 

Key words:

Instance of: to test whether an object is an instance of a class.

This: is the name of a reference that refers to an object itself.

Extends:

Implements:

Equals(): used to determine whether 2 objects have the same references.

==: compares the contents of two objects.

Public: the class, data and methods are all visible to any class in any package.

Private: The data or methods can be only accessed by the declaring class.

Protected: data or method can be accessed by any class in the same package or its subclass.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值