- constructor overloading:

  1. must have same name as class
  2. have no ‘void’ return type //void is returning null
  3. public

- methods(getter,setter) override

- override toString(built-in method)

public String toString(); //returning string type

{

return “\nName: “ + name + “\nAge: “ + age; //return only returns 1 datatype

}

// printf, println suppose to work with primitive datatype

- argument promotion:

promotion: conver to upper datatype.

ex. float → double, int → long, float, double

- Method call stack and stack frames:

  • FIFO(First In First Out): que
  • LIFO(Last In First Out): stack

- Scope of Declatations:

variable 가 선언 된 후 (int x) 그 블럭{} 안에서만 사용할 수 있다는 것. it is not transferring to other block.

- Method overloading:

method same name w/ different signature.(not parameter)

public static void xyz(int x, String y){

//body

}

how to override method?

  1. change number of parameters.(int x, String y, char z)
  2. change data type of parameters.(String x, int y)
  3. change order of parameters.(char x, int y, string z)

- Array:

array of specific datatype[ ]

- Enhance for loop:

for (int e : array)

system.out.printf(”\n%d”, e);

- Format specifier

%s = string

%d = double

%f = float or double

%n = line breaking

- instance variable?

- Package:

groups related classes, so that they could be imported into programs and reused.

-Access Modifier

ModifierClassPackageSubclassWorld(outside of package)
publicYYYY
protectedYYYN
no modifierYYNN
privateYNNN

-Inheritance

  • Object
    • Base class (= Parent class, Super class)
      • Derived class(=Child class, Sub class)

//field

protected int gear;

protected int speed;
public class Bicycle(int gear, int speed){}  ← Super class

class MountainBike extends Bicycle { ← Sub class

public mountainBike(int gear, int speed, int seatHeight){

super(gear, speed);

this.seatHeight - seatHeight;} 
}

-Abstract class

Abstract class can have both ‘abstract class’ and ‘concrete class’

profile
borison and me

0개의 댓글