This worksheet includes questions on Dart programming concepts, starting from basic syntax to intermediate and advanced levels.
Write a Dart program that prints:
Hello, Dart! Welcome to Programming.
Expected Output:
Hello, Dart! Welcome to Programming.
Write a Dart program to perform and print the following operations on two numbers a and b:
- Sum
- Difference
- Product
- Quotient
Assign a = 10 and b = 5.
Expected Output:
Sum: 15
Difference: 5
Product: 50
Quotient: 2.0
Write a Dart program to check if a given number is odd or even.
- Define a variable
num = 11. - Print "Even" if the number is even.
- Print "Odd" if the number is odd.
Expected Output:
The number is Odd.
Write a Dart program to perform addition, subtraction, multiplication, and division using functions.
- Use two inputs
a = 8andb = 4. - Create separate functions for each operation.
Expected Output:
Addition: 12
Subtraction: 4
Multiplication: 32
Division: 2.0
Write a Dart program to print the first 10 terms of the Fibonacci series.
The Fibonacci series starts with 0 and 1.
Expected Output:
Fibonacci Series:
0 1 1 2 3 5 8 13 21 34
Write a Dart program to:
- Create a list of integers:
[5, 3, 8, 1, 2]. - Add the number
7to the list. - Sort the list in ascending order.
- Print the sorted list.
Expected Output:
Sorted List: [1, 2, 3, 5, 7, 8]
Write a Dart program to:
- Create a set of unique integers:
{1, 2, 3, 4}. - Add a new number
5to the set. - Remove the number
2from the set. - Print the final set.
Expected Output:
Final Set: {1, 3, 4, 5}
Write a Dart program to:
- Create a map with the following key-value pairs:
{'name': 'Alice', 'age': 25, 'city': 'New York'}. - Add a new key-value pair:
'country': 'USA'. - Update the value of
'age'to26. - Print the updated map.
Expected Output:
Updated Map: {name: Alice, age: 26, city: New York, country: USA}
Write a Dart program to implement the Bubble Sort algorithm and sort a list of integers [5, 2, 9, 1, 5, 6] in ascending order.
Expected Output:
Sorted List: [1, 2, 5, 5, 6, 9]
Write a Dart program to implement the Binary Search algorithm. Search for the number 7 in the sorted list [1, 3, 5, 7, 9, 11]. If found, print its index.
Expected Output:
Number found at index: 3
Write a Dart program to create a class Car with the following properties:
brand(String)model(String)year(int)
Add a method displayInfo() that prints the car's details. Create an object of the Car class and call the displayInfo() method.
Expected Output:
Car Details:
Brand: Toyota
Model: Corolla
Year: 2020
Write a Dart program to demonstrate inheritance. Create a base class Animal with a method makeSound() that prints "Animal makes a sound". Create a derived class Dog that overrides the makeSound() method to print "Dog barks".
Expected Output:
Animal makes a sound
Dog barks
Write a Dart program with a function greet that takes two parameters: name (required) and message (optional). If message is not provided, default it to "Welcome".
Example Call:
greet("Alice");
greet("Bob", "Good Morning");Expected Output:
Hello Alice, Welcome
Hello Bob, Good Morning
Write a Dart program that uses an anonymous function to print the square of each number in a list: [1, 2, 3, 4, 5].
Expected Output:
Square of 1: 1
Square of 2: 4
Square of 3: 9
Square of 4: 16
Square of 5: 25
Write a Dart program to check if a given string is a palindrome. A string is a palindrome if it reads the same backward as forward. Test with the string "madam".
Expected Output:
The string 'madam' is a palindrome.
- Use
print()for output. - Arithmetic operations:
+,-,*,/. - Lists: Use
.add(),.sort(). - Sets: Use
.add()and.remove(). - Maps: Use
map[key] = value. - Sorting: Implement loops for Bubble Sort.
- Binary Search: Use iterative or recursive logic.
- Classes: Use
classandobjectinstantiation. - Inheritance: Use
extendsfor a subclass. - Optional parameters: Use
[]or{}for optional/ named parameters. - Anonymous functions: Use
list.forEach()with a lambda function.