Flutter

Dart Language Essentials

Classes, mixins, extensions, generics, async/await, streams, error handling

15 面接問題·
Junior
1

What is a mixin in Dart?

回答

A mixin is a way to reuse code across multiple class hierarchies without using traditional inheritance. Unlike single inheritance which limits to one parent class, mixins allow composing multiple behaviors into a single class using the with keyword. This promotes a more flexible architecture and avoids the problems of multiple inheritance.

2

What is the difference between an abstract class and an interface in Dart?

回答

In Dart, any class can serve as an interface using the implements keyword. The key difference is that an abstract class can contain method implementations that subclasses inherit, while an interface (via implements) forces the class to reimplement all methods. Use extends to inherit behavior and implements to guarantee a contract.

3

How to create an extension method in Dart?

回答

Extension methods allow adding functionality to existing types without modifying their source code. The syntax uses the extension keyword followed by an optional name, then on TypeName to specify the extended type. This feature is particularly useful for enriching third-party library classes or native types like String or List.

4

What is the role of the async keyword in a Dart function?

5

What is the difference between Future and Stream in Dart?

+12 面接問題

次の面接に向けてFlutterをマスター

すべての問題、flashcards、技術テスト、コードレビュー演習、面接シミュレーターにアクセス。

無料で始める