Skip to content
IT Courses
Courses
Blog
Search
/
VI
Quiz: Class trong TypeScript · TypeScript hiện đại: từ cơ bản đến nâng cao (TS 6 & 7)
Curriculum
›
6. Class trong TypeScript
Quiz: Class trong TypeScript
Mark as completed
← Previous
Next →
Comments
Question 1.
`{}`
`{"pin":"1234"}`
Lỗi runtime vì `pin` là private
`undefined`
Question 2.
Select all correct answers.
(1)
(2)
(3)
(4)
Question 3.
Select all correct answers.
`constructor(private name: string) {}`
`private name: string;`
`enum Role { Admin, User }`
`readonly id: string;`
Question 4.
`class Sq extends Shape { area() { return 4; } }`
`class Sq extends Shape { override area() { return 4; } }`
`class Sq extends Shape { override perimeter() { return 8; } }`
Cả a và b
Question 5.
Select all correct answers.
`new Report()`
`class A extends Report {}`
`class B extends Report { rows() { return ["x"]; } }`
`const r: Report = new (class extends Report { rows() { return []; } })();`
Question 6.
Có, vì `Vector` không kế thừa `Point`
Có, vì thiếu `implements Point`
Không, vì TypeScript so sánh kiểu theo cấu trúc
Không, vì class luôn là `any`
Question 7.
Select all correct answers.
Một class có thể `implements` nhiều interface
`implements` tự gán kiểu cho tham số method theo interface
`implements` chỉ kiểm tra class khớp interface, không thay đổi kiểu của class
Có thể dùng `instanceof` với interface
Question 8.
(1)
(2)
(3)
(4)
Check
TypeScript hiện đại: từ cơ bản đến nâng cao (TS 6 & 7)
Kiểm tra hiểu biết của bạn về class trong TypeScript.
Comments