Dart Programming Interview Questions and Answers
Question - 11 : - What is the use of this keyword in Dart?
Answer - 11 : -
In Dart, this keyword refers to the current instance of the class.
void main() {
Car c1 = new Car('E1001');
}
class Car {
String engine;
Car(String engine) {
this.engine = engine;
print("The engine is : ");
}
}
Question - 12 : - What are Getters and Setters?
Answer - 12 : - Getters and Setters allow the program to initialize and retrieve the value of class fields. It is also known as accessors and mutators.
Question - 13 : - What is type-checking in Dart?
Answer - 13 : -
In Dart, type-checking is used to check that a variable hold only specific to a data type.
String name = 'Smith';
int num = 10;
void main() {
String name = 1; // variable Not Match
}
Question - 14 : - What are various string functions in Dart?
Answer - 14 : -
There are given various string functions:
String Methods Description
toLowerCase() It converts all string characters in to lower case.
toUpperCase() It converts all string characters in this to upper case.
trim() It returns the string without any whitespace.
compareTo() It compares this object to another.
Question - 15 : - What is the file extension of Dart?
Answer - 15 : - The file extension of Dart is .Dart.
Question - 16 : - What is typedef in Dart?
Answer - 16 : -
In Dart, A typedef (Or function types alias) helps to define pointer to execute code within memory.
Syntax:
typedef function_name(parameters)
Question - 17 : - Which editor is used to enables breakpoint and step by step debugging?
Answer - 17 : - WebStorm editor is used to enables breakpoint and step by step debugging.
Question - 18 : - What Is Method Overriding In Dart?
Answer - 18 : -
In Dart, Method Overriding is a technique that child class redefines a method in its parent class.
Example:
void main() {
Child c = new Child();
c.m1(12);
}
class Parent {
void m1(int a){ print("value of a ");}
}
class Child extends Parent {
@override
void m1(int b) {
print("value of b ");
}
}
Question - 19 : - What is pub in Dart?
Answer - 19 : - In Dart, pub is a tool for manage Dart packages.
Question - 20 : - Does Dart have syntax to declare interface?
Answer - 20 : - No, Class declarations are themselves interfaces in Dart.