Seong+Jun

Seung Jun's Page Where are the notes on Abstract Classes? =Inheritance ( Object-oriented programming)= Incapsulation Encapsulation - Encapsulation is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism, and abstraction. Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. For this reason, encapsulation is also referred to as data hiding. Encapsulation can be described as a protective barrier that prevents the code and data being randomly accessed by other code defined outside the class. Access to the data and code is tightly controlled by an interface. The main benefit of encapsulation is the ability to modify our implemented code without breaking the code of others who use our code. With this feature Encapsulation gives maintainability, flexibility and extensibility to our code. ---> Subclass (child) ---> Superclass (parent)

Subclass can get the inheritance from Superclass 1. variable 2. public methods 3. public constan
 * not private variables - it can be used in Superclass only.

The biggest advantage of inheritance ---> I don't need to write again (reiterate)

Ex)

Superclass Student Name age grade

Subclass

High school Middle school Elementary school

Also, we can put some additional variable or method apart from inheritance [ superclass]
 * All these subclasses will have all the variables and methods that are mentioned in the superclass.


 * Multiple interitance doesn't happen in Java.

Superclass = original class, base class Subclass = new class, derived class

inheritance - public class SavintAccount **extends** BankAccount
 * inherits from BankAccount

Accesss Levels (not on the test) =Polymorphism= -> mechanism of program deciding which method to be executed -> it has to be overrider method --- overridden method
 * Modifier || class || package || subclass || world ||
 * public || Y || Y || Y || Y ||
 * protected || Y || Y || Y || N ||
 * no modifier || Y || Y || N || N ||
 * private || Y || N || N || N ||

Ex1 )

super -> the first __one-__ statement in the subclass constructor. --- use the word statement instead of one

Payment p1 = new payment (50000.0); Payment : object reference variable (it tells the type) like int, String p1 : Name, p1's location new payment (50000.0) : this is a real object.

We used use like cashPayment cpl = new cashPayment (50000.0); -> cashPayment for both time if cashPayment is the subclass of Payment class, we can write like Payment cpl = new cashPayment (50000.0); welll understood good! but it doesn't show the additional method that we used in cashPayment. -- do not use the word show but say "cannot call the additional methods that we used in cash payment"

Ex 2)

payment creditPayment = new creditPayment (50000.0, "2233", 5/10/2013)

we can't use creditPayment. paymentDetails c or credictPayment.getCardNo c We need to use casting to make it work. -> for overridden, we don't need to use casting. good --- Recursion -> calling the same method inside the method which means method that calls itself -> It is another control mechanism -> It is repetitive like loops

Things that Recursion method has to have -> basecase if there is no basecase, there is no end basecase is the number that comes at the end like 1 -> logic that leads toward the basecase as mentioned above, it is not going to end when there is no logic which leads to basecase

Strategy -> Firstly, we need to break the problem into smaller pieces -> we can deal with some of pieces immediately (basecase) -> Others need to be further broken up

ex)

public static int triangle (int n) { int (n==1) return 1; else return n+triangle(n-1); }

good notes! just know whatever prolem which can be sovled through recursion can be solved through iteration as well.