By GokiSoft.com|
13:22 24/02/2021|
Java Basic
[Share Code] Overview kiến thức basic trong lập trình Java
https://drive.google.com/file/d/1jtgRQ1w2aFFU8I_yD1u19rAiKFGSeoZM/view
Phần 1:
- Overview
- OOP (Class object, kế thừa)
- Kiến thức mới
- Tính chất trong lập trình OOP
- Tính chất đóng gói (Học rồi)
- Tính kế thừa (Học rồi)
- Tính đa hình -> ???
- Tính trừu tượng -> ???
- Static
- Test: Kiểm tra lại kiến thức
-> private: chỉ gọi đc trong chính nó
-> public: gọi đc ở tất cả mọi nơi
-> proteced: chính nó, cùng package, khác package trong TH kế thừa
-> default (friendly): chính nó, cùng package
#Test.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package aptech.lesson05;
/**
*
* @author Diep.Tran
*/
public class Test {
public Test() {
System.out.println("Test...");
}
public void display() {
showMenu();
}
public static void main(String[] args) {
Phone p1 = new Phone("A");
Phone p2 = new Phone("B");
System.out.println("P1 > " + Phone.YEAR);
System.out.println("P2 > " + Phone.YEAR);
// Test t = new Test();
//public, private, protected, friendly <-> protected
showMenu();
}
static void showMenu() {
System.out.println("1. Nhap 1");
System.out.println("2. Nhap 2");
System.out.println("...");
}
}
#Phone.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package aptech.lesson05;
/**
*
* @author Diep.Tran
*/
public class Phone {
String name;
static int YEAR;
public Phone() {
}
public Phone(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
void showHello() {
System.out.println("Hello");
}
}
#BPhone.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package aptech.lesson05_2;
import aptech.lesson05.Phone;
/**
*
* @author Diep.Tran
*/
public class BPhone extends Phone{
public static void main(String[] args) {
// BPhone bp = new BPhone();
// bp.test();
Phone p = new Phone();
}
public void test() {
System.out.println("Test...");
// showHello();
}
}
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)