Exam Dart
Exam Dart
Exam Dart
Exercise1
Write a program that prompts the user to input an integer and then outputs the number with
the digits reversed. For example, if the input is 12345, the output should be 54321.
import 'dart:io';
import 'dart:convert';
void main() {
print("Enter your number");
var number = int.parse(stdin.readLineSync().toString());
var Reuslt=ReverseNumber(number);
print("the result is $Reuslt");
}
Exercise2
Write a Dart function which will take an array of numbers stored and find the second lowest
and second greatest numbers, respectively. Sample array : [7,2,10,41,35]
import 'dart:io';
import 'dart:convert';
void main() {
var mylist2=[54,66,78,2,3,100];
maxSec(mylist2);
}
class Point {
int _x, _y;
Point(this._x, this._y);
void move(int mx, int my) {
_x += mx;
_y += my;
}
void display() {
print("x = $_x y = $_y");
}}
class PointCol extends Point {
int? Color_reference;
Exercise 4
1. Create a class called BankClient that have 3 private attributes :
C. ID which is generated automatically and represents the order of the client in the bank
Data Base (starting from 1 and can't be changed).
D. Name (can't be changed).
E. Balance have 3 methods (get, add, subtractIfPossible).
class Bankclient{
int? _Id;
String? _Name;
double? _Balance;
static List namesList=[];
static List<double> BalanceList=[];
static List IdList=[];
Bankclient(String names){
_Name=names;
namesList.add(names);
}
double addBalance(double amount) {
double bal=amount;
BalanceList.add(bal);
return bal;
}
double getBalance() {
return _Balance!;
}
dynamic subtractIfPossible(double amount){
if(_Balance!>amount){
double bal =_Balance!-amount;
return bal;
}
else{
return "error!";
}
}
static void dispBalName() {
var sum=0.0;
BalanceList.forEach((ele) => sum += ele);
print("the number of clients is ${namesList.length} and the balance is ${sum}");
}
}
Exercise 5
1-Dart MCQs
1. Dart is an?
A. open-source
B. general-purpose
C. programming language
D. All of the above
A. Microsoft
B. Google
C. IBM
D. Facebook
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
A. declare()
B. list()
C. main()
D. return()
A. Enables assertions
B. Displays VM version information
C. Specifies the path
D. Specifies where to find imported libraries
A. Yes
B. No
C. Can be yes or no
D. Can not say