Object-Oriented Java OCA

Object-Oriented Java OCA

  1. Class, Method, Variable, Scope

  2. Inherit Encapsulation 封装 polymorphism 多态

  3. 组合与关系

1. Class, Method, Variable, Scope

  1. 8 Basic Type

    • boolean char byte short int long float double

    • Currency BigDecimal

  2. Method

    • <Access Modifier> <Return Type> <Method Name> <Parameter List> {Body}

    • {Body} return void

    • Override and Overwrite

        * Override - Actions and decisions are overriden.
        * Overload - Information is overwritten.
    • Pass By Value | Pass By Refernece

        * Three return types for methods; must use one: primitive type, reference type, or void
    • Scope

        1. Local Variable 
        2. Method Parameter
        3. Instance Variable
    • Constructor Function / default Constructor / Constructor Overload

    • this - super

        * super use parent class in current class method or contstructor
    • Static Method / Variable

  3. Inherit, Encapsulate

    1. Abstract

    2. Implement, Interface

    3. Access Modifier

    4. Encapsulate Setter / Getter

IDAbstract ClassInterface
1An abstract class can extend only one class or one abstract class at a timeAn interface can extend any number of interfaces at a time
2An abstract class can extend another concrete (regular) class or abstract classAn interface can only extend another interface
3An abstract class can have both abstract and concrete methodsAn interface can have only abstract methods
4In abstract class keyword “abstract” is mandatory to declare a method as an abstractIn an interface keyword “abstract” is optional to declare a method as an abstract
5An abstract class can have protected and public abstract methodsAn interface can have only have public abstract methods
6An abstract class can have static, final or static final variable with any access specifierinterface can only have public static final (constant) variable
  1. Polymorphism

    1. Set Theory Transitive

        * Inherit  A ∪ B ∪ C ∈ R
        * Polymorphism A ∩ B ∩ C ∈ R
    2. overloading means there are several methods present in a class having the same name but different types/order/number of parameters.

Referenced

  1. Method overriding

  2. Access Modifiers in Java

  3. Java Inheritance Quiz

  4. Difference Between Abstract Class and Interface in Java

  5. Java polymorphism quiz

  6. How do I understand the class return type in Java?

标签: none

添加新评论