Learn Dart: First Step to Flutter Educative Quiz Answers

Get Learn Dart: First Step to Flutter Educative Quiz Answers

Learn Dart for free with this interactive course. Dart is a clean, simple, class-based object-oriented language that has more structure than JavaScript, the programming language it’s heavily based on.

However, you can’t have a conversation about Dart without mentioning Flutter.

Flutter is Google’s mobile UI framework used for crafting high-quality native interfaces on iOS and Android. Flutter applications are written using the Dart programming language, which has helped make Dart a beloved language by the developer community. Before you can start fluttering out applications using Flutter, you need to learn Dart.

This course will help you learn the fundamentals of Dart, and get you started on your journey to learning Flutter. Start learning today.

Enroll on Educative

Challenge 1: Displaying Output

Answer:

print("My mamma always said, life is like a box of chocolates. You never know what you're gonna get.");


Quiz 1:

Q1. What constitutes as an application entry point in Dart?

  • Hello World
  • Any named function
  • The main() function
  • All of the above
  • None of the above

Q2. What does it mean for a programming language to be imperative?

  • Describes what a program should accomplish in a sequential manner
  • Describes how a program should accomplish a goal in a sequential manner
  • Describes when a program should accomplish a goal in a sequential manner
  • All of the above
  • None of the above

Q3. What is a library in computer programming?

  • A collection of similar code that you can reference in your own code
  • A collection of text which you can refer to in your own code
  • A collection of all the availaible pre-written code you can reference in your own code
  • All of the above
  • None of the above

Q4. What is the purpose of the dart:io library?

  • Provides input support
  • Provides output support
  • Provides support for non-web applications
  • All of the above
  • None of the above

Q5. Which of the following programs would you use to get input from the user?

  • Option 1:
main() {
    stdin.readLineSync();
}
  • Option 2
import 'dart:io';

main() {
    stdin.readLine();
}
  • Option 3
import 'dart:io';

main() {
    stdin.readLineSync()
}
  • All of the above
  • None of the above

Challenge 2: Embed a Variable in a String

Answer:

print("$name is $age years old.");


Quiz 2:

Q1. Variables are used for storing data.

  • True
  • False

Q2. What role does the variable name play when declaring a variable?

  • Decides the data type of the variable
  • Declares the initial value of the variable
  • Acts as an identifier for the variable
  • All of the above
  • None of the above

Q3. What type includes integers and doubles?

  • Num
  • num
  • numbers
  • Numbers
  • All of the above
  • None of the above

Q4. What is the default value of an uninitialized variable?

  • 0
  • null
  • nothing
  • All of the above
  • None of the above

Q5. In which of the following examples are we not assigning a literal to the variable b?

  • Option 1
main() {
  var a = 1;
  var b = a;
}
  • Option 2
main() {
  var a = 1;
  var b = 'a';
}
  • Option 3
main() {
  var a = 1; 
  var b = 1;
}  
  • All of the above
  • None of the above

Q6. What is string interpolation?

  • Embedding strings with numbers
  • Embedding strings with variables
  • Embedding strings with expressions
  • All of the above
  • None of the above

Q7. What would the output be of the given code?

main() {
  print("3 + 2 = ${3 + 2}");
}
  • 5
  • 3 + 2 = 5
  • 3 + 2 = ${3 + 2}
  • All of the above
  • None of the above

Q8. Which of the following examples is using type inference?

  • Option 1
main() {
    bool variable = true;
}
  • Option 2
main() {
    num variable = 5;
}
  • Option 3
main() {
    var variable = 'hello';
}
  • All of the above
  • None of the above

Q9. Which of the following comes first?

  • Compile-time
  • Run-time

Challenge 3: Using Multiple Operators

Answer:

var compareCheck = (check < 75) && (check >= 8);

Challenge 4: Temperature Conversion

Answer:

var celsius = (fahrenheit - 32) * 5 / 9; 

Quiz 3:

Q1. What makes an expression different from a simple statement?

  • An expression evaluates to a value
  • An expression does not have a resulting value
  • Every statement is an expression
  • All of the above
  • None of the above

Q2. Which of the following describes infix notation?

  • Operator is before the operands
  • Operator is between the operands
  • Operator is after the operands
  • All of the above
  • None of the above

Q3. Select the correct output for the following code:

main() {
  int operand1 = 7;
  int operand2 = 3;

  print(operand1 ~/ operand2);
}
  • 2
  • 2.3333333333333335
  • 3
  • All of the above
  • None of the above

Q4. Select the correct output for the following code:

main() {
  var operand1 = 's';
  var operand2 = 'q';

  print(operand1 == operand2);
}
  • Error
  • true
  • false
  • All of the above
  • None of the above

Q5. Select the correct output for the following code:

main() {
    var A = true;
    var B = true;
    var exp = A || B;

    print(false && exp);
}  
  • true
  • false
  • exp
  • All of the above
  • None of the above

Q6. Select the correct output for the following code:

main() {
  var operand1 = 7;
  var operand2 = 3;

  print(operand1 & operand2);
}
  • 3
  • 7
  • 10
  • All of the above
  • None of the above

Q7. Select the correct output for the following code:

main() {
  var operand1 = 7;
  var operand2 = 3;
  operand1 += operand2;

  print(operand1);
}
  • 3
  • 7
  • 10
  • All of the above
  • None of the above

Q8. Select the correct output for the following code:

main() {
  var operand = 7;

  print(operand++);
}
  • 7
  • 8
  • 9
  • All of the above
  • None of the above

Q9. Which of the following is correct in terms of operator precedence (from left to right)?

  • <*&
  • !=|^
  • ==:( )
  • All of the above
  • None of the above

Challenge 5: List of Cubes

Answer:

var cubes = integers.map((integer) => integer * integer * integer).toList();

Quiz 4:

Q1. How many built-in core collections does Dart provide?

  • 2
  • 3
  • 4
  • None of the above

Q2. What does it mean for a collection to be ordered?

  • The collection cannot have duplicates
  • Elements don’t have a fixed position
  • Elements have a fixed position
  • All of the above
  • None of the above

Q3. What will be the output of the following code?

main() {
  var temp = [6,8,23,97,10];

  var index = temp.indexOf(8);
  temp.removeAt(index);

  print(temp);
}
  • [6, 23, 97, 10]
  • [8]
  • [6,8, 23, 97, 10]
  • All of the above
  • None of the above

Q4. Choose the correct syntax for the map() method.

  • map.listName((iterator) => statement);
  • listName.map(iterator => statement);
  • listName,map((iterator) => statement);
  • All of the above
  • None of the above

Q5. What will be the output of the following code?

main() {
  var temp = {6,8,23,97,10};
  var temp2 = {8,25,7,1,90,34,23,10};

  var intersectionSet = temp.union(temp2);
     
  print(intersectionSet);
}
  • {}
  • {8,23,10}
  • {6, 8, 23, 97, 10, 25, 7, 1, 90, 34}
  • All of the above
  • None of the above

Q6. What comes first when creating a map?

  • key
  • value
  • None of the above

Q7. Which of the following uses indexes?

  • Map
  • List
  • Set
  • All of the above
  • None of the above

Challenge 6: Pass or Fail

Answer:

// Check if student has passed or failed
if (percentage >= 60 && percentage > (average-5)){ 
  print("pass");
}else { 
  print("fail");
}  

Challenge 7: Only Even

Answer:

var evenList = List();

for(var i = 0; i <integers.length; i++){
  if((integers[i] * 3) % 2 == 0){
    evenList.add(integers[i] * 3);
  }  
}

Challenge 8: Oven is Ready

Answer:

while (temperature<375) { 
  temperature += 25;
  count +=1;
}

Challenge 9: Color Wheel

Answer:

switch(color) {
  case "blue":
    print("orange");
    break;
  case "yellow":
    print("purple");
    break;
  case "red":
    print("green");
    break;
  default:
    print("not a primary color");
}

Quiz 5:

Q1. What are control structures used for?

  • Control structures are used for determining the output of a statement
  • Control structures dictate the flow in which statements are executed
  • Control structures are diagrams used for understanding the flow of execution
  • All of the above
  • None of the above

Q2. What will be the output of the following code?

main() {
  var a = 7;
  var b = 2;
  
  var result = a>b ? b-a : a-b;
  print(result);
}
  • error
  • 5
  • -5
  • None of the above

Q3. What will be the output of the following code?

main() {
  var list = [1,2,3,4,5];

  for (var i in list) {
    if (i % 2 != 0) {
     print(i);
    }
  }
}
  • Option 1
1
2
3
4
5
  • Option 2
1
3
5
  • Option 3
2
4
  • There will be no output
  • None of the above

Q4. What will be the output of the following code?

main() {
  dynamic constantPattern= List();

  switch(constantPattern){
    case 5:
      print("five");
      break;
    case true:
      print("truth");
      break;
    case "hello":
      print("hi!");
      break;
    case null:
      print("the empty list");
      break;
    default: 
      print("something else");
      break;
  } 
}
  • “something else”
  • “the empty list”
  • null
  • error
  • None of the above

Q5. How many times will the print() method be called in the following code?

main() {
  var experience = [5,1,9,7,2,4];

  for(var i = 0; i < experience.length; i++){
    var candidateExperience = experience[i];
    if(candidateExperience < 5){
      continue;
    } else {
      break;
    }
    print("Call candidate $i for an interiew.");
  }
}
  • None
  • 2
  • 3
  • Error
  • None of the above

Q6. What will happen when we run the following code?

main() {
    assert((3 << 1) == 7);
}
  • The assertion is true, hence the code will execute successfully
  • The assertion is false, however, the code will still execute successfully
  • The assertion is false, hence, an exception will be thrown
  • None of the above

Challenge 10: Absolute Value

Answer:

num absolute(num x) {
  var abs = x < 0 ? -x : x;
  return abs;
}

Challenge 11: Sum of Lists

Answer:

int sum(List<int> numberList, int index) { 
  if(index < 0 ){
    return 0; 
  } else {
    return numberList[index] + sum(numberList, index-1);
  }  
}

Challenge 12: Write your First Higher-Order Function

Answer:

num arithmeticCalculator(Function f, int x, int y){
  return f(x,y);
}

Challenge 13: Max with Nested Functions

Answer:

int mainMax(int a, int b, int c) {
  int max(int x, int y) {
    if(x > y){
      return x;
    } else{
      return y;
    }  
  }
  return max(a,max(b,c));
}

Quiz 6:

Q1. Which of the following are optional when defining a basic function?

  • function body wrapped in curly brackets and parameter type
  • parameter type and return type of the function
  • parameters wrapped in parenthesis and parameter type
  • All of the above
  • None of the above

Q2. Is the below function declaration using named parameters or positional parameters?

String param(String a, int b,  [num c]) {
}
``
  • positional paramerters
  • named parameters
  • All of the above
  • None of the above

Q3. What does it mean for a function to be treated as a first-class value?

  • A function can be passed as a parameter
  • A function can be returned as a result
  • A function is treated like a basic data value such as an integer.
  • All of the above
  • None of the above

Q4. The code snippets below are anonymous functions which return the product of two numbers. Which of the following is the correct implementation?

  • Option 1
(x,y) {
    x*y;
  } 
  • Option 2
(x,y) {
    x*y;
  } ;
  • Option 3
x,y {
    x*y;
  } 
  • All of the above
  • None of the above

Q5. What is syntactic sugar?

  • It’s just a cool way of saying ‘sweet syntax!’
  • Syntax which changes the functionality of the code
  • Syntax that makes code easier to read and express
  • All of the above
  • None of the above

Quiz 7:

Q1. A blueprint is used to create identical copies of the same object.

  • True
  • False

Q2. The members of a class can be divided into the following two parts:

  • Methods and Variables
  • Methods and Properties
  • Methods and Instance Variables
  • All of the above
  • None of the above

Q3. Why is an object known as an instance of a class?

  • Just a naming convention
  • An object is an instantiated class
  • An instance is a singular occurrence of something the same way an object is a single occurrence of a class
  • All of the above
  • None of the above

Q4. The code below declares an EqualShape class and creates its instance, square, whose property, numOfSides, is assigned a value of 5.

Why will the code not compile?

class EqualShape{
  var numOfSides=0;
  var lengthOfSides=0;

  perimeter() {
    return numOfSides * lengthOfSides;
  } 
}

int main() {
  var square = EqualShape;
  square.numOfSides = 5;
}
  • The code will compile
  • Incorrect object declaration
  • Incorrect class declaration
  • Members of the class are incorrectly defined
  • None of the above

Q5. What will be the output of the following code?

class EqualShape{
  var numOfSides = 0;
  var lengthOfSides = 0;

  perimeter(){
    return numOfSides * lengthOfSides;
  }  
}

int main() {
  var shape = EqualShape();
  shape.numOfSides = 5;
  shape.lengthOfSides = 5;
  var result = shape.perimeter();
  print(result);
}
  • 25
  • 0
  • Error
  • None of the above
Conclusion:

I hope this Learn Dart: First Step to Flutter Educative Quiz Answers would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published.