Posts by Chang Park

extends (and super) vs. implements


  • extending a class
    • A extends B
      • Both classes or both interfaces
  • extends parent class’ already defined methods
  • Also possible to override the methods


  • Super
    • With using super, you can call parent’s variable and methods.
      • Ex) super.p1 (variable), super.getName() (method)
    • Also, you can call parent’s constructor itself


it calls parent class Base’s a variable





it calls parent Base’s show() method





  • implementing an interface
    • A implements B
      • A is class, and B is an interface
  • multiple interfaces can be implemented(separated by comma)
  • you cannot implement declared methods
  • you need to specify the method before using




  • Famous Framework using php
  • MVC
    • Model: interacts with database
    • View: Presentation side
    • Controller: Intermediary between model and view

Interface vs. Abstract class vs. Concrete class


  • uses “implements” to be implemented
  • multiple interfaces can be implemented
  • interface can extends only interface


abstract class

  • uses “extends” to be extended
  • if it includes at least one abstract method, it should be declared as an abstract class.
    • abstract method: undefined method
    • concrete method: defined method
  • There are already defined methods also
  • Abtract class extends both regular class and abstract class.


Concrete class

  • uses “extends” to be extended
  • Concrete class has only concrete methods(already defined).
class Example{

   public void display1(){
      System.out.println("display1 method");
   public void display2(){
      System.out.println("display2 method");



  • Variable cannot be changed

final int num=3;


  • Method cannot be modified
final String getNumber() {
   return "result";


  • Nobody can extend this class
  • That means, no body can override methods of this class
  • Possible to use as it is(not modifying).
public final class String{



Soot program converts Android application file into Jimple code.

Jimple contains two general concepts

  • Local – local variables
  • Units – statements



  • $r0 := @this: de.ecspride.RV2013;
  • $r1 := @parameter(): android.view.View;



  • Assignments between locals, constants, and fields



  • Right-hand side of the assignment is a typecast
  • $r4 := (android.widget.EditText) $r1;


Four different expressions to call methods

  • VirtualInvokeExpr
    • Virtual dispatch invoke to an instance method
  • StaticInvokeExpr
    • Calling a static method
  • InterfaceInvokeExpr
    • Calling a method of an object of which only its interface type is known
  • InvokeStmt
    • Any invoke expression which can be part of standalone statement

super vs. this

  • super : used to access methods of the base class
  • this : used to access methods of the current class

superTHis1 superThis2

The third line is printing “animal : eat” because we are calling

If we called, it would have printed “dog : eat”.

http vs. https (and SSL)

http (hypertext transfer protocol)

  • transfer hypertext data
  • port: 80

https (hypertext transfer protocol over secure sockets layer)

  • Secure called webpage and data
  • But slower the transferring speed
  • Port: 443

SSL (Secure Sockets Layer)

  • Encryption: Hiding what is sent from one computer to another
    • Computers agree on how to encrypt
    • Server sends a certificate
    • Client’s computer says “start encrypting”
      • in here there are 3 messages
        • Client key exchange: Both computers calculate a master secret code
        • Change cipher spec: client’s computer is asking server to encrypt
        • Finished: let’s start now
      • The server says “start encrypting”
        • in here there are 2 messages
          • change cipher spec: I’m going to send encrypted message now
          • finished: let’s go
        • This message gets encrypted
      • All messages are now encrypted
        • It will look as a garbage to other
  • Identification: Making sure the computer you are speaking to is the one you trust
    • 1. Company asks CA(Certificate Authority) for a certificate
      • The company asks CA for a certificate
        • The web server
        • What the company is
        • Where it is located
      • Certificate Authority checks correctness and authenticity of company
    • 2. CA creates certificate and signs itSSL1
    • 3. Certificate installed in server
      • The company will run a web server
      • The certificate is installed into this server
      • The web server is configured to use the certificate
    • 4. Browser issued with root certificates
      • You can check installed certificate authorities on your computer.
      • On my computer(mac), I can check with Keychain Access applicationSSL2
    • 5. Browser trusts correctly signed certs
      • Client’s computer has public key of the certificate authority
      • When it receives a certificate, it will verify a encrypted signature of the certificate with the public key.

Overloading vs. Overriding


  • When making multiple methods with using same method’s name
  • Parameter has to be different



  • When trying to edit parent class’ method.
  • Method name and parameter has to be same
  • @override is not necessary, but better to write.
  • It is better to write @override before the method.
    • pros
      • Compiler will check error when you make mistake while overriding such as misspelling method name.
      • Otherwise you won’t know whether you made a mistake, and also you will get unexpected behavior
      • Readabilty both for other developers and for you



Overloading: In same class, make same named methods with different return type or parameter.

Overriding: Redefining parent’s method. One of Polymorphism which is characteristic of object oriented programming .

Levenshtein Distance


Levenshtein distance (LD) is a measure of the similarity between two strings, and it is a minimum costs to transform a string to the other using deletions, insertions, or substitutions. This is really useful algorithm for comparing two strings.


Screen Shot 2016-07-17 at 12.17.24 AM

As shown on the algorithm table, make a calculated distance table.

Next, initialize first row and column as 0 – (m or n).

Get minimum value of left one +1upper one +1, and diagonally above and to the left + cost.

Example ( GUMBO & GAMBOL )

Screen Shot 2016-07-17 at 12.33.39 AM

Step 7 

final Levenshtein Distance is lower right hand corner of the matrix which is 2 in this case.

Java Code

public class Distance {

  // Get minimum of three values

  private int Minimum (int a, int b, int c) {
  int mi;

    mi = a;
    if (b < mi) {
      mi = b;
    if (c < mi) {
      mi = c;
    return mi;


  // Compute Levenshtein distance

  public int LD (String s, String t) {
  int d[][]; // matrix
  int n; // length of s
  int m; // length of t
  int i; // iterates through s
  int j; // iterates through t
  char s_i; // ith character of s
  char t_j; // jth character of t
  int cost; // cost

    // Step 1

    n = s.length ();
    m = t.length ();
    if (n == 0) {
      return m;
    if (m == 0) {
      return n;
    d = new int[n+1][m+1];

    // Step 2

    for (i = 0; i <= n; i++) {
      d[i][0] = i;

    for (j = 0; j <= m; j++) {
      d[0][j] = j;

    // Step 3

    for (i = 1; i <= n; i++) {

      s_i = s.charAt (i - 1);

      // Step 4

      for (j = 1; j <= m; j++) {

        t_j = t.charAt (j - 1);

        // Step 5

        if (s_i == t_j) {
          cost = 0;
        else {
          cost = 1;

        // Step 6

        d[i][j] = Minimum (d[i-1][j]+1, d[i][j-1]+1, d[i-1][j-1] + cost);



    // Step 7

    return d[n][m];



Android Application


  • Written in Java language
  • They are compiled to Android’s own bytecode format, Dalvik executable(DEX)
  • Doesn’t have a single entry-point, such as the main method in Java
  • Four components
    • Activities: visible parts of an application
    • Services: run in the background and are not interacting with the user directly, used for long running background such as mp3 playback
    • Broadcast receivers: react to global events, such as incoming calls or text messages
    • Content providers: implement domain-specific databases for, e.g. contacts
  • onCreate(): gets called when the activity is launched for the first time
  • Android Emulator: virtual mobile device that runs on a computer and is similar to a real device.
  • Android API calls
    • Log.i(String tag, String msg):
      • Static methods which writes an info messages to the log
      • The log can be browed using the tool LogCat
    • findViewById(int id)
      • returns references to GUI objects